with
and alias
keywords
#214
orenelbaum
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If we add placeholders to pipeline operators, we could do something similar to old JS's
with
:We could also maybe support assignment:
although this is not necessarily as straight forward as it might seem.
I'm proposing reviving the
with
keyword, but unlike the oldwith
, use it with placeholders to make it less terrible, and make it assignable.This could support aliases and multiple parameters:
Or with a combination of an alias and placeholders for documentation purposes
Also like
if
andfor
, this could support implicit return and being used as an expression.A related proposal, made by @edemaine, is
alias
declarations, that introduce a binding to the current scope.This is pretty powerful and could even be used to create reactive variables similar to Svelte:
Both proposals have nuances and I think there's a lot to think about, but I also think that they could be very handy in some situations.
Beta Was this translation helpful? Give feedback.
All reactions