indexing tuples using strings

bearophile bearophileHUGS at lycos.com
Tue Dec 2 02:26:18 PST 2008


Bill Baxter:

>What about Perl shows that auto-flattening is bad?<


You can find a note here:
http://steve.yegge.googlepages.com/ancient-languages-perl
>
Larry decided to flatten lists by default. Hence, if you write this:
@x = (1, 2, 3, (4, 5));
It automagically turns into (1, 2, 3, 4, 5).
<

With Google you can find many other pages that about that anti-feature.
The new version of Perl, that is in development from some years, fixes this, I think.

The ability of creating trees with arbitrary nested tuples/arrays is really handy (I don't know if the variant type of Tango allows to do this. The boxed of Phobos doesn't allow it, I think).


>Isn't there an easier way to fake it using structs?<

In my dlibs I've added a Record/record that can be used a little as a Python tuple, the Record can be found here:
http://www.fantascienza.net/leonardo/so/dlibs/templates.html

Bye,
bearophile



More information about the Digitalmars-d mailing list