tuple sumlimation

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Tue Feb 13 20:09:16 PST 2007


Bill Baxter wrote:
> Kevin Bealer wrote:
>> Currently, Tuples are sublimated into argument lists.  What do people 
>> think of using an operator (say, *) to prevent this?  The reason I ask 
>> is that the current technique makes it hard to pass multiple tuples on 
>> the same function call.
>>
>> I think it's not absolutely required; currently you can pass the tuple 
>> lengths, let the tuples melt together, and then split them with slicing.
>>
>> Kevin
> 
> I think Walter and Andrei are very aware that the inability to make 
> Tuples hierarchical is a hindrance to many kinds of algorithms.
> 
> But definitely some way to make hierarchical tuples is a must.  Lisp 
> without nested lists is close to useless.

It's funny this came up. It was only our last discussion that we talked 
about the issue. I compared the mistake of flattening tuples with that 
of flattening Perl function array arguments. Perl has suffered from it, 
and now has an alternative mechanism (reference) to deal with that; the 
plan is to turn D's semantics around while there is time. This is 
particularly important for the upcoming AST manipulation abilities. ASTs 
might be unified with tuples; if you flatten the tuples, they aren't 
trees anymore and you lose information, unless you plan to flatten them 
the Forth way :o).

> The * type of syntax is used in Python to control expansion of tuples 
> into arguments.  Though I think it's kind of backwards from what you're 
> saing -- func(*args) causes args to be passed as separate arguments, 
> func(args) passes it as a single argument that is a tuple.  Personally I 
> think that makes more sense.   Automatically expanding as the default is 
> kind of odd.  No other argument type modifies itself in funky ways when 
> you pass it to a function.

Agreed.


Andrei



More information about the Digitalmars-d mailing list