JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.14k stars 5.43k forks source link

single-value tuple destructuring syntax? #203

Closed StefanKarpinski closed 12 years ago

StefanKarpinski commented 12 years ago

This works:

julia> (x,) = m.captures
("capture",)

but this doesn't:

julia> x, = m.captures
syntax error: extra input after end of expression

Would it make sense to allow this slightly odd syntax for destructuring a single value from a tuple?

JeffBezanson commented 12 years ago

eew, that's strange.

StefanKarpinski commented 12 years ago

You mean the syntax or the difference between with and without parens?

JeffBezanson commented 12 years ago

a, = b looks strange, and might be difficult to parse.

StefanKarpinski commented 12 years ago

Ok... we'll take that as a "no" :-P

JeffBezanson commented 12 years ago

well, most important thing is to decide if we want it. if people really want it i can probably make it happen. i don't really care either way though.

StefanKarpinski commented 12 years ago

Let's skip it. Seems too weird. If this becomes something people clamor for, we can reconsider.