retard wrote: > Mon, 15 Feb 2010 01:08:38 -0500, Nick Sabalausky wrote: > >> "BCS" <[email protected]> wrote in message >> news:[email protected]... >>> 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.
You can do the same in D of course, lambda's and closures are available after all. But with a string mixin you can print the line / file info (at least you need this for D1, in D2 there is another way) AND the source code of the expression itself. That is quite useful for unittesting. Can you do that in scala?
