www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Overloading Lazy Vs. Non-Lazy

reply Pillsy <pillsbury gmail.com> writes:
Steven Schveighoffer Wrote:
[...]
 Hold on, can't we have enforce and lenforce (lazy enforce)?

Or couldn't we have an overload for enforce that takes a string, and another overload that takes a void delegate returning a string? It makes the syntax a little grottier, but...
  From a simple grep, 99% of enforce instances are:

 enforce(condition)
   -or-
 enforce(condition, "compile-time-string")
   -or-
 enforce(condition, "compile-time-string" ~ type.stringof)

...if you have to write enforce(condition, (){ return "compile-time-string" ~ type.stringof; }); one time in a hundred, is it really that bad? Cheers, Pillsy
Aug 12 2010
parent dsimcha <dsimcha yahoo.com> writes:
== Quote from Pillsy (pillsbury gmail.com)'s article
 ...if you have to write
     enforce(condition,
                (){ return "compile-time-string" ~ type.stringof; });
 one time in a hundred, is it really that bad?
 Cheers,
 Pillsy

I think the point was that even this should be automagically evaluated at compile time, since type.stringof is a compile time constant.
Aug 12 2010