Const template

Bill Baxter dnewsgroup at billbaxter.com
Sun Jan 21 21:49:21 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:

> Anyhow, speaking of a more critical review, the current intended rules 
> for lazy are:

Does the lack of syntax mean that the syntax has yet to be decided upon?

> * lazy is a type constructor (takes a type, returns a type)

Cool that seems like an interesting idea for this and const.

> * sizeof(lazy T) = sizeof(T delegate())
> 
> * initialization = expression of type T or expression of type lazy T
> 
> * assignment: expression of type lazy T
> 
> * access: every access invokes the delegate. No trailing parens.
> 
> * deduced automatically: never

What does this mean, exactly?  Is it speaking of a template parameter? 
Or for things like 'auto foo = <expr>'?

> * can occur in: (a) function argument list; (b) function return type; 
> (c) all lvalue contexts (namespace-level, local, struct member, class 
> member, array, hash)

> One irregularity is that assignment from an expression of type T is not 
> accepted, amid fears that this would cause confusion. Probably we could 
> drop this irregularity.

So this is ok:
   lazy int a = 3+4;
And this is ok:
   lazy int b = 3+4;
   lazy int a;
   a = b+2;

But this is not?
   lazy int a;
   a = 3+4;


Don't really have any criticisms of this at the moment, just trying to 
figure out exactly what it's going to mean in practice.
So far what I'm getting is that it's similar to the current 'lazy' just 
generalized to apply to more situations, and that now lazy is part of 
the type rather than being a storage class.

Will there be any additional interop with delegates?  What about 
assigning a delegate to a lazy variable?

--bb



More information about the Digitalmars-d mailing list