I haven't run into that confusion myself, but it makes sense. Is it clearer when there's literals involves? (which is often the case w/ matching like this)
i.e. match (x) { {foo: 1} => ... } (vs {foo: bar})
-
-
Replying to @maybekatz
Yeah it's clearer that way. The issue for me is stuff like: let { person: { name: n } } = contact; ^ it takes me some effort every time to remember that n is the variable being bound here.
1 reply 0 retweets 1 like -
Replying to @wycats
I wonder if there's any way to address that. I can see how the : might make people think "variable-value-is: <val>". Because Language™
1 reply 0 retweets 1 like -
Replying to @maybekatz
I think what we did in modules is pretty good but it came pretty late and we didn't retrofit destructuring: let { person: { name as n } } = contact For me, this is eminently more readable and clear, especially when syntax highlighted.
1 reply 0 retweets 2 likes -
Replying to @wycats @maybekatz
I periodically fantasize about bringing this up even now, because it has another use that's not covered by existing syntax: let { person: { first, last } as p } = contact For the case where you want the whole object and components
1 reply 0 retweets 2 likes -
Replying to @wycats
I'm proposing `var@123` in the bikeshed section, since that's what most pattern engines use.
1 reply 0 retweets 0 likes -
Replying to @maybekatz
Rust has `@` to the left and it's ... Ok (no pun intended). I think it's not ideal to reuse the @ sigil (inside a class, it'll become hard to pick out this syntax vs decorators). We could reuse sigils in diff contexts, but I tend to feel that we should try to avoid if possible.
1 reply 0 retweets 2 likes -
Replying to @wycats
As long as we have a way to do this kind of assignment, I'm cool with wherever the bikeshed goes. I still prefer @ for its terseness and how it allows plain matchers. I also suspect it's easier to read when you're binding a big obj ("everything after this" vs "everything before")
1 reply 0 retweets 0 likes -
Replying to @maybekatz
I wouldn't cry if we got @. That said, could still possible use a word with car on the left: let { p is { first, last } } = person match (contact) { ({ person: p is { first, last } }) ... }
1 reply 0 retweets 1 like -
Replying to @wycats
A word with car on the left, eh? Is that a green light for me to propose car/cdr/cddr/cadr/cadar/cdadar? ((((((((((
))))))))))1 reply 0 retweets 3 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
