On Sun, 10 Oct 2010 17:39:52 +0400, Stephan Soller
<stephan.sol...@helionweb.de> wrote:
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
Exactly. To be honest, I see absolutely no reason to have yet another to
declare structs, but some people have other preferences.
I don't mind having Tuple in a library, as long as I'm not insisted in
using it *and* it doesn't affect other language features.
I mean, it's not even shorter to write
alias Tuple!(int, "x", int, "y", int, "z") Coord;
than
struct Coord { int x; int y; int z; }