New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard, array & map functions: Equivalencies #843
Comments
@ChristianGruen in these two excellent tables, could you somehow add a visual device to distinguish between 4.0 and non-4.0 functions? Then it will be easier to identify those functions that cannot be tampered with. |
One challenge in a search for consistency, is that of domains. The This touches on the issue of naming conventions. When Note, when the |
Thanks. The 4.0 functions are the ones with the keyword new attached; if the function is followed by a question mark, there may be an existing issue for its addition, or it may be consistent to add it. I’ve just updated the table to reflect the latest changes.
Yes, that’s a valid point. Personally, I would be happy if we deliberately chose different names for sequence functions. We should just be aware of the consequences. The discussion on |
@dnovatchev I like your push forward to find a more general solution to the naming problem. I just don’t know what it could look like (maybe others don’t either). Would you be willing to open a new issue and make some suggestions on how we could proceed? |
From my perspective, we should align names when we can, but we should expect and embrace the asymmetry. We should not conclude something is wrong if we cannot, nor should we presume that any new function in one area will necessarily spawn O(M * N) functions. In sum, this comment argues for preserving the status quo, making small adjustments where possible. The On the other hand, the We do this in OOP all the time. If we are working with a project that has a date object, a car object, and a thingy object, we do not expect the date object to have a speed method, nor the car object to have a time zone property, and we do not know what kinds of properties or methods a thingy object would have. The nature of the object drives its properties and methods. I think the underlying principles we have used to date are sound. In sum, I don't think there's a significant problem here. We can make slight alignments/adjustments where possible. Anyone who doesn't like the standard function names and arity can write their own function library, refactoring, regrouping, and re-aliasing the functions as they wish, and share the results with developers of like mind. I've done a bit of this myself in the past. But it need not occupy WG time and energy. |
Thanks, Joel. I completely agree. My hope is that we can go through the list together in the meeting and decide which functions we want to keep as is, and which of the functions tagged with question marks we want to add or not. Hopefully, by simple majority vote, this won't take longer than 15 minutes. As a result, we may be able to close several other open issues. |
💯 |
One general question here is: Do we need all the complementing functions for arrays that don’t exist yet ( |
I would be quite happy to drop those that appear to have little value, or that make little sense in the context of arrays. For example I don't believe |
My minimized proposal would be to…
…and skip the addition of equivalent array functions, at least in the scope of this issue. Suggestions are welcome. |
|
Thanks.
I would define it as suggested in the referenced comment (#260 (comment)). |
We need some powerful way to examine arrays - something that combines the proposed for removal I would love to have:
And also:
and:
It is not a coincidence that LINQ provides very similar function to these. |
What do these functions actually do? We can't guess from their names. How does Is Is |
That comment proposes to use |
Yes, it seems to be equivalent to
As we have started using the word "where" in other function names, we could continue this systematic naming approach, and use the same word "where" here.
Yes, but is twice shorter ... and twice less error-prone and time-consuming. Also, considerably easier to understand - thus significantly more readable.
Yes, but is twice shorter ... and twice less error-prone and time-consuming. Also, considerably easier to understand - thus significantly more readable. Also, |
I can see what are your concerns. We could possibly atomize the search items before applying It's true that |
Perhaps then |
The CG decided to close this issue without further action at meeting 067. |
In many threads (#135, others), we have discussed how to align the functions for sequences, arrays, and maps. This is an attempt to summarize the status quo, and I hope to keep it up-to-date in the coming weeks.
The 4.0 functions are the ones with the keyword new attached. If the function is followed by a question mark, there may be an existing issue for its addition, or it may be consistent to add it.
Please note that the data types have fundamental differences, so it’s not always possible to present or provide exact symmetries.
To be discussed
fn:contains-subsequence
new: #94, #844
array:contains-subarray
?map:contains
fn:ends-with-subsequence
new: #96, #844
array:ends-with-subarray
?fn:starts-with-subsequence
new: #96, #844
array:starts-with-subarray
?fn:distinct-values
array:distinct-members
?fn:duplicate-values
new: #123
array:duplicate-members
?fn:empty
array:empty
new: #229map:empty
? #827fn:exists
array:exists
new: #229map:exists
? #827fn:every
newarray:every
?map:every
?fn:some
newarray:some
?map:some
?fn:highest
newarray:highest
?fn:lowest
newarray:lowest
?fn:index-of
array:index-of
? #260fn:index-where
newarray:index-where
new: #114
map:keys($m, $pred)
new: #467
fn:items-at
new: #213→
fn:get
? #872array:members-at
? #825array:get
map:get
fn:intersperse
new: #2→
fn:join
? #868array:join
fn:subsequence-where
new: #878
array:subarray-where
?fn:substitute
? #553, #583array:replace
new;array:substitute
? #583map:replace
new;map:substitute
? #583fn:slice
newarray:slice
newarray:split
newmap:entries
newarray:values
newmap:keys
;map:values
newarray:entries
? #826map:entries
newarray:merge
? #826map:merge
map:entry
array:members
new → keep? #826
map:pairs
new → keep? #826
array:of-members
new → keep? #826
map:of-pairs
new → keep? #826
map:pair
new: #508 → keep? #826
Settled
fn:count
array:size
map:size
fn:filter
array:filter
map:filter
fn:fold-left
array:fold-left
fn:fold-right
array:fold-right
fn:for-each-pair
array:for-each-pair
fn:for-each
array:for-each
map:for-each
fn:head
array:head
fn:insert-before
array:insert-before
fn:remove
array:remove
map:remove
fn:reverse
array:reverse
fn:sort
array:sort
fn:subsequence
array:subarray
fn:tail
array:tail
array:put
;array:append
map:put
fn:foot
new: #250array:foot
new: #250fn:trunk
new: #250array:trunk
new: #250The text was updated successfully, but these errors were encountered: