On 14/11/20 7:45 am, Brandt Bucher wrote:
with (using your own syntactic flavor): ``` case >first, *>middle, >last: rebuilt = first, *middle, last case {"key": >value, **>rest}: rebuilt = {"key": value, **rest} case Point(x=>a, y=>b): rebuilt = Point(x=a, y=b)
I think this is a case where syntax matters. To my eyes this looks far less confusing: case ?first, *?middle, ?last: rebuilt = first, *middle, last case {"key": ?value, **?rest}: rebuilt = {"key": value, **rest} case Point(x=?a, y=?b): rebuilt = Point(x=a, y=b)
(I had to stop and think *hard* where exactly the `>` should go in `*middle` and `**rest`.
There's a simple rule -- the "?" goes directly in front of the thing being assigned. You're assigning to 'middle', not '*middle', so it's '*?middle', not '?*middle'. I know the same rule applies whatever sigil is being used, but to my way of thinking, '>' is too easily confused with a comparison operator. Also it's tempting to interpret '=>' as a single token, which accidentally happens to make sense here, but could mislead people into writing '*=>middle' instead of '*>middle'. -- Greg