Tuple literal syntax
Stephan Soller
stephan.soller at helionweb.de
Sun Oct 10 06:39:52 PDT 2010
On 07.10.2010 17:36, Andrei Alexandrescu wrote:
> On 10/7/10 10:13 CDT, Kagamin wrote:
>> Andrei Alexandrescu Wrote:
>>
>>> struct Coord
>>> {
>>> int x, y, z;
>>> }
>>>
>>> one iota typesafer than
>>>
>>> alias Tuple!(int, "x", int, "y", int, "z") Coord;
>>
>> Is there a real need for an alternative way to declare structs?
>
> Yes.
>
> Andrei
I agree but I also don't agree. I like the possibility to return
multiple values (quite handy in Ruby, PHP and other languages) and
therefore we need language constructs to group multiple values and
ungroup them again.
However as soon as these fields are named it looks to me like an
ordinary structure. So why not just create something like an "anonymous
structure literal" that behaves to structures like anonymous functions
(or delegates) to functions?
This would look a lot more consistent to me than playing around with
different kinds of tuples. However I'm not sure about the details (e.g.
how would such structures handle type or alias contents).
Happy programming
Stephan
More information about the Digitalmars-d
mailing list