Jacob Carlborg wrote: > On 2010-11-21 01:23, Jonathan M Davis wrote: >> On Saturday 20 November 2010 08:03:52 Jacob Carlborg wrote: >>> Why don't you use delegates instead of string mixins? For example, >>> assertExcThrown, could take a delegate which calls the function you want >>> to test instead of a string that represents the call. The mixin want be >>> needed as well. Am I missing something? >> >> Well, delegates wouldn't be a bad idea, but they're unwieldy too. Would >> you rather write >> >> assertExcThrown!Exception((){func(param1, param2);}); >> >> or >> >> mixin(assertExcThrown!(Exception, `func(param1, param2)`)); > > I would go with the delegate, but when you format the code like that it > doesn't look any good (btw, no need for the extra pair of empty > parentheses). I think this looks better: > > assertExcThrown!Exception({ > func(param1, param2); > }); > > And BTW, D needs a better way to pass a delegates to a function, > something like the syntax that can be used in Scala: > > assertExcThrown!Exception { > func(param1, param2); > }
This is possible, but too surprising: assertExcThrown!Exception = { func(param1, param2); }; with lazy: assertExcThrown!Exception = func(param1, param2);