Eliminate assert and lazy from D?

Frank Benoit keinfarbton at googlemail.com
Mon Oct 12 23:51:16 PDT 2009


Jeremie Pelletier schrieb:
> 
> For example, there is no way to tell a parameter is lazy from a function
> call, you need to look at the prototype. But the same can be said with
> ref and out too so if you remove lazy you also need to rethink these two.
> 

ref and out are not the same category of weirdness for the caller. the
compiler will tell that a lvalue is needed for ref and out. But the
expression may have side effects, evaluating never/once/multiple is easy
to hide errors.

> I therefore made myself a simple convention on how I use lazy: if the
> value is evaluated only once I use lazy, otherwise I use a delegate.
> This makes it clear from the call context what I'm doing.

If it is evaluated exactly once, you do not need lazy at all. And if it
may also not be evaluated, the callers code is not less safe as when
evaluated multiple times.



More information about the Digitalmars-d mailing list