Tango BitArray Initialization

Sean Kelly sean at f4.ca
Sun Feb 11 19:41:48 PST 2007


Colin Huang wrote:
> John Reimer Wrote:
> 
>> (The last line could be legal if an opCall were implemented.)
> 
> Even if an opCall overload were in place, I doubt that the last line would
 > compile. It certainly didn't last time I tried (I'm using gdc 0.22 on 
Windows).
> I may be wrong on this, of course.
> 
> In fact, I've been wanting to be able to do that for quite some time now, so I
 > can use structs like stack-allocated objects in C++ (syntax-wise, at
> least).   If it actually works, pls give some examples. thx

I don't think this is legal in D.  In fact, the syntax is a huge problem 
in C++ because the parser often can't distinguish between a variable 
decl and a function prototype, and function prototypes take precedence. 
  It may be uglier, but:

     BitArray b = BitArray( 1, 0, 1 );

is better than:

     BitArray b( 1, 0, 1 );

I only wish that the syntax worked for all stack variables.  ie.

     int x = int( 1 );


Sean


More information about the Digitalmars-d-learn mailing list