Trouble creating a formatted assert wrapper

Chris Nicholson-Sauls ibisbasenji at gmail.com
Wed Sep 5 11:51:58 PDT 2012


On Tuesday, 4 September 2012 at 11:28:23 UTC, Don Clugston wrote:
> I don't know how that could be done. You need to know the 
> function signature whenever you call the function. If you make 
> the signature dependent on the function body, it cannot work 
> unless you have the source code of the function. The compiler 
> is able to add hidden variables for things like 'this' because 
> it can work out if it is required just by looking at the types 
> involved in the function declaration. But in this case, it 
> can't get it from the signature.
>
> The default argument method we are currently using is a nice 
> trick, because even though default arguments aren't part of the 
> function type, the compiler still sees them in the function 
> signature, so it knows to do a bit of magic.
>
> It's also easy to get nasty forward reference errors when you 
> do that sort of thing.
>

Fair enough; I hadn't considered the case of having only the 
signature to go by.  Maybe an @attribute for it?  ;)  Okay okay, 
I give.  For now there's making file/line template params, which 
is fine for something like a custom assertion meant for debug 
builds, although horrid for release builds.


More information about the Digitalmars-d mailing list