August 15, 2007 Re: __FUNC__ in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote: > Regan Heath wrote: >> On 2nd thought I think this only works by some sheer coincidence and fluke! > > The whole idea is a hack. Hacks are only /suposed/ to work when the user does things exactly right True. There are many combinations which will break it, i.e. const(char) baz() will get a function called "const", an extra check of p[start..end] using isKeyword would fix a few of these sorts of problems. >> A better one could definately be written with the DMDFE. > > yes but do you want to port DMDFE to run using CTFE? Actually I think I have some code to lex C/C++ here somewhere and with very few changes it would lex D just as well. That would be easier that using a full blown DMDFE port. I might see what I can whip up tomorrow (it's 11pm here). Regan |
August 16, 2007 Re: __FUNC__ in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Amazing! I greatly appreciate your help! |
September 18, 2012 Re: __FUNC__ in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | > No.
The question is "Why not?". For a language that is supposed to have good compile time relfection, and wants to have good runtime relection, this basic inability illustrates an area in dire need of attention.
I don't think a solution is to introduce __FUNC__, that will only add on to the already big clutter pile. A more generalized solution is to introduce self-referencing (and then get rid of some of the clutter).
Eg
void function x()
{
writeln( typeof(self).stringof );
}
Even better, using the uniform calling syntax convention
void function x()
{
writeln( self.typeof.stringof );
}
--rt
|
Copyright © 1999-2021 by the D Language Foundation