jastrachan | 17 Dec 23:14 2004
Picon

Re: tuple return


On 17 Dec 2004, at 22:05, John Rose wrote:
> On Dec 17, 2004, at 13:48, jastrachan@... wrote:
>
>> That opens a little can of worms in the parser I'd imagine? Also that 
>> begs the question...
>>
>>     x = 1, 2
>>
>> is x a list, or array etc?
> Yes, that's too ambiguous, at least if you try to work tuples into the 
> expression language.

Agreed.

> Example:  def x = 1, y.   One tuple variable or two variables?
> Syntax is easy to fix, though; it's probably enough to require 
> parentheses:  return (1,2), (x,y) = (y,x), etc.
> At worst, some sort of ugly noisy tuple operator:  return #(1,2), 
> #(x,y) = #(y,x)
>
> Better yet, I was thinking the job of tuples might be handled by 
> lists, given the right semantics for matching of lvalues which are 
> explicit list constructors:  [x,y] = [y,z]

Thats an idea. Not support tuples in the language (as its too much of a 
radical change & causes ambiguity all over the place) but use list 
notation on the lvalues

[a, b, c] = [x, y, z]

I like it.

I don't think 'tuple returns' are so common as to require a drastic 
language change; so using the list notation on lvalues sounds a neat 
solution to me.

> FP languages have data structure matching like that; it's really 
> handy.  Sort of a 2.0 thing, maybe.

Definitely - I'd like us to sort out the basics ASAP :)

James
-------
http://radio.weblogs.com/0112098/


Gmane