Re: Multi-assign
- Posted by jimcbrown (admin) Nov 16, 2011
- 2613 views
A new keyword is a really bad idea.
I agree with you, but I am curious as to why you think that.
I just thought using a keyword would be too confusing, as it'd be too easy to think it was a variable name or something.
The preference for a shift-less character is not so important as the feature would not be a commonly used one.
We use shifted characters all the time for more commonly used expressions, like and'ing two sequences together.
I think we need to have a glyph of some sort, and a visually prominent one would be preferable. We should try to avoid characters that are potentially typos.
Agreed. This arguably takes the underscore out of the equation as well (as it could be a typo on either side - variable named "_math" turned into "_,math" or something).
So I think we are left with the single characters ... "@%^&*?" , and maybe combinations like "[]".
{ A, [], B } = SomeFunc(1, [], 2)
This one I really like. It stands out to me.
Problem is, it could be a double typo ("[]" when "p[0]" was meant for example).
{ A, @, B } = SomeFunc(1, @, 2)
I could live with this.
{ A, %, B } = SomeFunc(1, %, 2) { A, ^, B } = SomeFunc(1, ^, 2) { A, &, B } = SomeFunc(1, &, 2) { A, *, B } = SomeFunc(1, *, 2) { A, ?, B } = SomeFunc(1, ?, 2)
These all look like operations to me. Even the caret (we don't use it, but it reminds me of power() in other languages).