Curry underscore arguments to create anonymous functions [Go/No Go] #49351
Replies: 9 comments 22 replies
-
Strictly speaking, those are not the only two options to get headless anonymous function syntax --- that comment was within the context of that particular proposal. Note that there are other proposals in this family with the triage label, eg #38713, which has turned into a bunch of various proposals too. |
Beta Was this translation helpful? Give feedback.
-
It's not clear to me what this rule means: is it one and exactly one call, or at most one call? Could someone maybe write down a few examples of how option (2) would be parsed? Eg how would it work with things like |
Beta Was this translation helpful? Give feedback.
-
Personally, I'd vote for option (2) - having It would be very valuable to have this implemented by a dispatchable type that |
Beta Was this translation helpful? Give feedback.
-
@LilithHafner would triage option two allow for something like |
Beta Was this translation helpful? Give feedback.
-
I think (2) would be better than nothing, though it seems like a pain to implement. |
Beta Was this translation helpful? Give feedback.
-
An issue with special-casing "operator calls" is that the distinction is quite blurry. g(_) ∈ x # definitely an "operator"
g(_) in x
in(g(_), x)
occursin(g(_), x)
h(g(_), x) # definitely not an "operator" or -f(_) # definitely an "operator"
√f(_)
√(f(_))
sqrt(f(_))
exp(f(_))
g(f(_)) # definitely not an "operator" No matter at what step Julia decides that the input isn't an "operator" anymore, two extremely similar/equivalent forms will parse in completely different ways. And the error messages in case of "unexpected" parsing wouldn't really be helpful, according to the todays situation. |
Beta Was this translation helpful? Give feedback.
-
Why isn't scala-like tight-binding an option (i.e. consume 1 call)? Weighing pros/cons: 1 call + operators Pro: Con: Qn: Would 1 call (tight-binding) Pro: Con: The surface area of unintuitive cases for 1 call+ops (e.g. Here's a macro-based demo for one vision for how tight-binding might work, here. |
Beta Was this translation helpful? Give feedback.
-
How does (2) How |
Beta Was this translation helpful? Give feedback.
-
To play devil's advocate - one could argue that we currently have a different LHS behavior in the language: _, b, _, d = (1, "b", :c, 'd') The natural interpretation here is, I would argue, that we assign |
Beta Was this translation helpful? Give feedback.
-
Triage previously decided that, in the context of #24990, when it comes to special parsing for underscores to create anonymous functions, "the only viable options are (1) do nothing, or (2) consume one call followed by zero or more operator calls."
I would like to either
_
to create autonomous functions is not for Julia 1.x so that I can give up on this; orTo that end, I'm opening a discussion here explicitly scoped to the question: of options (1) and (2), which is better? Triage's decisions can certainly be revised, but I'd like to keep that discourse out of this discussion thread. For additional options, please feel free to continue the discussion at #24990 or related issues and PRs. This discussion thread is intended to solicit asynchronous public comment (traige is also open to the public) on the specific question above, hopefully in a concise enough format that folks can actually read it.
Edited to include @tpapp's correction
Beta Was this translation helpful? Give feedback.
All reactions