Does D support anonymous structs?

Derek Parnell derek at psych.ward
Wed Feb 22 22:35:29 PST 2006


On Thu, 23 Feb 2006 17:26:13 +1100, Derek Parnell wrote:

> With anonymous structs, the definition *is* the declaration.

Sorry, but I forgot something nice. Anonymous structs don't seem to be
solving any problem that I've come across, but anonymous unions are very
nice.
 
 struct S
 {
   int type;
   union { 
      int i; 
      long l;
      short s;
      real r;
      float f;
      Foo foo;
   }
 }
 
 S s;
 s.type = 1;
 s.i = 88;

 ...
 s.type = 3;
 s.r = 88.98;


-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
23/02/2006 5:32:34 PM



More information about the Digitalmars-d mailing list