change mixins

retard re at tard.com.invalid
Mon Feb 15 03:19:03 PST 2010


Mon, 15 Feb 2010 01:08:38 -0500, Nick Sabalausky wrote:

> "BCS" <none at anon.com> wrote in message
> news:a6268ff103d38cc7ba48d6fabda at news.digitalmars.com...
>> Hello Nick,
>>
>>> I *definitely* want that for string mixins of both the
>>> template-generated and ctfe-generated varieties.
>>>
>>>
>> Why? I don't see any reason aside from documentation to do it.
>>
>>
> Well, for one thing, not having it forces any code using my
> custom-assert library to look like this crap...
> 
> mixin(deferAssert!(`foo == 3 || foo > 5`, "foo is bad"));
> 
> ...which understandably no one wants to touch and I *absolutely* don't
> blame them one bit. Compare that to this...
> 
> deferAssert!(`foo == 3 || foo > 5`, "foo is bad");
> 
> ...ahhh, now I can actually see what the hell's going on!

To me it's not clear why you just can't do this with higher order 
functions. For instance in Scala I would just write:

object MyUnitTestFramework {
  def deferAssert(pred: => Boolean, msg: String) {
    if (pred) println(msg)
  }
}

or whatever functionality you might want. Passing the predicate by name 
does not force evaluation yet on the call site.



More information about the Digitalmars-d mailing list