@jar1: We already have a shorter alternative to begin a; b end
for blocks: (a; b)
@jules: Appreciated. Considering that {...}
parses differently than blocks anyway, that was a good move imo.
I do like the idea of having a more-verbose block syntax for multi-line {...}
. Is there any analogy here? I don’t believe I’ve encountered any more-verbose block syntax for [...]
.
The let-end semantics is arguably much more common and natural in this context
@aplavin: I agree, I don’t like side-effects here; that’s why I’ve chosen to make x.{f, g}
mean let it=x; it=f(it); it=g(it); it end
.
This also makes its scope behavior consistent when you say: chain={f, g}; x.{chain}
, because {f, g}
means it->(it=f(it); it=g(it); it)
I’ve actually even gone a step further, and made it so that any local assignments have the local
keyword prepended—that’s how much I dislike side effects
@adienes and @Barget: The thing you must understand, is that the behavior of underscores in PR#24990 is incompatible with their behavior in Chain.jl. For example, PR#24990 would propose that map(_^2, _)
should create a function that behaves like x->map(y->y^2, x)
, whereas Chain.jl treats it as if it’s x->map(x^2, x)
.
You have two possible paths:
-
Adopt underscore behavior like Chain.jl, which then makes it impossible to use _
for partial application (at least, if we are to demand any consistency in language behavior).
-
Adopt underscore behavior like PR#24990. This allows underscore partial application both inside- and outside-of chains.
You choose path (2), as it offers the ability to write _+1
instead of Base.Fix2(+, 1)
, as well as opening up all sorts of other partial application applications (e.g. if a function composition fallback is implemented, you could write filter(_%3==0, arr)
).
However, you soon run into the problem that you can’t make expressions where the same variable appears more than once: _+_^2
doesn’t behave as x->x+x^2
and instead throws an error. But you say, “This is a chain! Of course I meant the result of the last expression!”
You might go back and decide that you prefer (1). But that would prevent partial application syntax outside of chains, and you would burn _
on something which didn’t need it (remember that we’re creating a new context, in which we are at liberty to choose new keywords!).
So then you say, okay. Let’s choose path (2), and select a local keyword. You survey the landscape of identifiers. You consider ⬚
, but it’s difficult to type. Then you realize, singular non-gendered object pronouns carry the exact meaning that you are after here. So then you arrive at it
, and the exact behaviors of this proposal.
Which brings us back to: