digitalmars.D - __FUNCTION__
- Jarrett Billingsley (1/1) Feb 28 2009 Can we get this please? It's so simple and would be terribly useful.
- BCS (2/4) Feb 28 2009 ++vote;
- Nick Sabalausky (3/7) Feb 28 2009 repeat(1, BCS_comment());
- dsimcha (4/5) Feb 28 2009 Can someone explain what __FUNCTION__ would do in a little more detail? ...
- Nick Sabalausky (16/24) Feb 28 2009 void foofunc()
- Jarrett Billingsley (3/9) Feb 28 2009 It would probably be the fully-qualified name, especially when you
- Andrei Alexandrescu (8/37) Feb 28 2009 I think instead of __FUNCTION__ we'll define a much more comprehensive
- BCS (3/8) Feb 28 2009 for the above case I think __FUNCTION__ is as good as it will get. Defin...
- Andrei Alexandrescu (5/19) Feb 28 2009 You will have it as a human readable identifier too. The problem with
- grauzone (5/26) Feb 28 2009 For classes and structs, this is already possible: typeof(this).stringof
- Jarrett Billingsley (10/14) Feb 28 2009 Oh, that'd be nice. It'd be even nicer if .stringof had any more
- Andrei Alexandrescu (5/30) Feb 28 2009 Not outside of a member function. This is crippling my Visitor
- Christopher Wright (5/15) Feb 28 2009 I use it in static constructors. If it doesn't work, well, that's news
- Andrei Alexandrescu (3/22) Feb 28 2009 Compile-time. Runtime follows and only needs a little glue.
- Christopher Wright (9/33) Mar 01 2009 That glue requires user intervention. Would you add "mixin(Reflect);" to...
- Nick Sabalausky (4/28) Feb 28 2009 *smacks self in forehead*, You know, I've even used that in my own code
- Edward Diener (12/32) Feb 28 2009 These macros are the wrong idea. As you say the bare macros can go on
- Andrei Alexandrescu (5/10) Feb 28 2009 D2 will have reflection. (Walter doesn't know yet. He thinks D3 will
- Jarrett Billingsley (4/14) Feb 28 2009 Will it be implemented through __traits, or *yet another* compile-time
- Andrei Alexandrescu (4/18) Feb 28 2009 Whatever it'll be, I'm sure it will not shut off your whine noise
- Jarrett Billingsley (5/9) Mar 01 2009 :P
- Leandro Lucarella (12/24) Mar 02 2009 It will be nice not to use a keyword starting with "__" for a standard
- Edward Diener (26/37) Feb 28 2009 The whole debate about "compile-time" and "run-time" reflection is
- Andrei Alexandrescu (11/53) Feb 28 2009 This is a long discussion, but in brief any runtime reflection engine
- Edward Diener (6/60) Mar 01 2009 It was written because I have inevitably seen discussions about language...
- Walter Bright (3/8) Feb 28 2009 I believe it is a great idea, it's just that there are so many that I'm
- Denis Koroskin (9/42) Feb 28 2009 Yes. When writing a recursive function, it is often desired to have a wa...
- Johan Granberg (2/60) Feb 28 2009 "fthis" does not sounds like a nice keyword. How about "self"?
- Andrei Alexandrescu (10/68) Feb 28 2009 We better use "..".
- Jarrett Billingsley (3/11) Feb 28 2009 I hope this is a sarcastic reply :P
- Andrei Alexandrescu (3/17) Feb 28 2009 My second. I was afraid the first one wasn't transparent enough.
- Ary Borenszweig (2/21) Feb 28 2009
- Andrei Alexandrescu (3/23) Feb 28 2009 That's the one! I think it even got a serious answer :o).
- Georg Wrede (4/27) Mar 01 2009 Sarcasm starts working against the author if
- Derek Parnell (37/38) Feb 28 2009 void foo()
- Jarrett Billingsley (5/38) Feb 28 2009 I mentioned in a follow-up post that it would probably have to give a
- Derek Parnell (11/26) Feb 28 2009 Ah yes, I read that now ... {note to self: Should read all posts before
- Jarrett Billingsley (4/9) Feb 28 2009 Then, as Andrei suggested, we need a more flexible and fine-grained
- Derek Parnell (9/11) Feb 28 2009 Agreed, but are you also suggesting that a simple __FUNCTION__ should al...
- Andrei Alexandrescu (3/14) Feb 28 2009 I don't know much about APL, what was wrong with it?
- Walter Bright (2/3) Feb 28 2009 It needed a special keyboard.
- Christopher Wright (3/7) Feb 28 2009 There is an input method for APL that supports standard keyboards, I
- Walter Bright (3/11) Feb 28 2009 Yeah, many kludge-o-matic workarounds have appeared over the years, none...
- Georg Wrede (11/26) Mar 01 2009 Plenty.
- bearophile (4/5) Feb 28 2009 I'll try to put some humorous answers of this kind in my posts too, it w...
Can we get this please? It's so simple and would be terribly useful.
Feb 28 2009
Hello Jarrett,Can we get this please? It's so simple and would be terribly useful.++vote;
Feb 28 2009
"BCS" <none anon.com> wrote in message news:a6268ff30f38cb67a8ee93108e news.digitalmars.com...Hello Jarrett,repeat(1, BCS_comment());Can we get this please? It's so simple and would be terribly useful.++vote;
Feb 28 2009
== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articleCan we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.
Feb 28 2009
"dsimcha" <dsimcha yahoo.com> wrote in message news:goc1k7$qml$1 digitalmars.com...== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articlevoid foofunc() { Stdout.formatln("{}", __FUNCTION__); } Output: foofunc Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways. Also, I'd like to be able to do something like: Reflect.invoke(__FUNCTION__, params); Something funtionally equiveilent to that would aid maitenance of self-invoking functions (not only recusion, but also func overloads that are defined in terms of one "primary" overload). Also would be nice for similar reasons: __CLASS__ (or something similar that would also work for structs)Can we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.
Feb 28 2009
On Sat, Feb 28, 2009 at 2:15 PM, Nick Sabalausky <a a.a> wrote:void foofunc() { =A0 =A0Stdout.formatln("{}", __FUNCTION__); } Output: foofuncIt would probably be the fully-qualified name, especially when you consider using it for reflection.
Feb 28 2009
Nick Sabalausky wrote:"dsimcha" <dsimcha yahoo.com> wrote in message news:goc1k7$qml$1 digitalmars.com...I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articlevoid foofunc() { Stdout.formatln("{}", __FUNCTION__); } Output: foofunc Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways.Can we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.Also, I'd like to be able to do something like: Reflect.invoke(__FUNCTION__, params);Yah... and Variant needs to have something similar as well. We know quite what std.reflect needs to look like, just we want to keep our fingers out of too many pies at once.Something funtionally equiveilent to that would aid maitenance of self-invoking functions (not only recusion, but also func overloads that are defined in terms of one "primary" overload). Also would be nice for similar reasons: __CLASS__ (or something similar that would also work for structs)Yah. Andrei
Feb 28 2009
Hello Andrei,Nick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.
Feb 28 2009
BCS wrote:Hello Andrei,You will have it as a human readable identifier too. The problem with __FUNCTION__, __CLASS__ etc. is that the list of ad-hoc names (what happened to __STRUCT__, __MODULE__ et al?) can go forever. AndreiNick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.
Feb 28 2009
Andrei Alexandrescu wrote:BCS wrote:For classes and structs, this is already possible: typeof(this).stringof Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.Hello Andrei,You will have it as a human readable identifier too. The problem with __FUNCTION__, __CLASS__ etc. is that the list of ad-hoc names (what happened to __STRUCT__, __MODULE__ et al?) can go forever.Nick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.Andrei
Feb 28 2009
On Sat, Feb 28, 2009 at 4:10 PM, grauzone <none example.net> wrote:For classes and structs, this is already possible: typeof(this).stringof Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.Oh, that'd be nice. It'd be even nicer if .stringof had any more documentation than "returns a string representation of something." Like what format it's supposed to be in, what you're supposed to get when you get the string of something like: struct S { int x; } pragma(msg, S.x.stringof); that kind of stuff. As it is I have *no* idea if any of my uses of stringof are legal, and it worries me even more that other compilers will freely implement it any way they choose, breaking my code on anything but DMDFE.
Feb 28 2009
grauzone wrote:Andrei Alexandrescu wrote:Not outside of a member function. This is crippling my Visitor implementation.BCS wrote:For classes and structs, this is already possible: typeof(this).stringofHello Andrei,You will have it as a human readable identifier too. The problem with __FUNCTION__, __CLASS__ etc. is that the list of ad-hoc names (what happened to __STRUCT__, __MODULE__ et al?) can go forever.Nick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.There's much more to reflection that we need to define. Andrei
Feb 28 2009
Andrei Alexandrescu wrote:grauzone wrote:I use it in static constructors. If it doesn't work, well, that's news to me. I don't know about "typeof(this) property;", though. I never tried it.For classes and structs, this is already possible: typeof(this).stringofNot outside of a member function. This is crippling my Visitor implementation.Runtime as well as compile time.Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.There's much more to reflection that we need to define.
Feb 28 2009
Christopher Wright wrote:Andrei Alexandrescu wrote:Compile-time. Runtime follows and only needs a little glue. Andreigrauzone wrote:I use it in static constructors. If it doesn't work, well, that's news to me. I don't know about "typeof(this) property;", though. I never tried it.For classes and structs, this is already possible: typeof(this).stringofNot outside of a member function. This is crippling my Visitor implementation.Runtime as well as compile time.Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.There's much more to reflection that we need to define.
Feb 28 2009
Andrei Alexandrescu wrote:Christopher Wright wrote:That glue requires user intervention. Would you add "mixin(Reflect);" to every class you wrote? But even that isn't sufficient -- you would have to implement some interface indicating that this class has reflection information, and pass objects around via that interface rather than using Object. There should be a way to suppress emitting complex reflection information -- a command-line flag and a pragma. But I think it's a bit much to ask users to mark every class they create in two different ways.Andrei Alexandrescu wrote:Compile-time. Runtime follows and only needs a little glue.grauzone wrote:I use it in static constructors. If it doesn't work, well, that's news to me. I don't know about "typeof(this) property;", though. I never tried it.For classes and structs, this is already possible: typeof(this).stringofNot outside of a member function. This is crippling my Visitor implementation.Runtime as well as compile time.Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.There's much more to reflection that we need to define.Andrei
Mar 01 2009
"grauzone" <none example.net> wrote in message news:goc97a$15il$1 digitalmars.com...Andrei Alexandrescu wrote:*smacks self in forehead*, You know, I've even used that in my own code already, and still didn't think of it when I made that post.BCS wrote:For classes and structs, this is already possible: typeof(this).stringof Now we only need a way to get some kind of compile time object for functions and modules (like the type for classes/structs). Then you simply can use .stringof on them.Hello Andrei,You will have it as a human readable identifier too. The problem with __FUNCTION__, __CLASS__ etc. is that the list of ad-hoc names (what happened to __STRUCT__, __MODULE__ et al?) can go forever.Nick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.
Feb 28 2009
Andrei Alexandrescu wrote:BCS wrote:These macros are the wrong idea. As you say the bare macros can go on forever. What is really needed in a reflection library is the ability to 'reflect' all D constructs, and you would get much more than just the name in such a library. So pushing for __FUNCTION__, __CLASS__ etc. etc. is just a quick-fix solution whereas a real reflection library gives so much more. I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.Hello Andrei,You will have it as a human readable identifier too. The problem with __FUNCTION__, __CLASS__ etc. is that the list of ad-hoc names (what happened to __STRUCT__, __MODULE__ et al?) can go forever.Nick Sabalausky wrote:for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.Stdout.formatln("{}", __FUNCTION__);I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.
Feb 28 2009
Edward Diener wrote:I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point. Andrei
Feb 28 2009
On Sat, Feb 28, 2009 at 10:49 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Edward Diener wrote:Will it be implemented through __traits, or *yet another* compile-time introspection facility?I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point.
Feb 28 2009
Jarrett Billingsley wrote:On Sat, Feb 28, 2009 at 10:49 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Whatever it'll be, I'm sure it will not shut off your whine noise generator :o). AndreiEdward Diener wrote:Will it be implemented through __traits, or *yet another* compile-time introspection facility?I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point.
Feb 28 2009
On Sat, Feb 28, 2009 at 11:46 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote::P I wasn't whining about it, I'd just rather not see a fifth method of compile-time introspection.Will it be implemented through __traits, or *yet another* compile-time introspection facility?Whatever it'll be, I'm sure it will not shut off your whine noise generator :o).
Mar 01 2009
Jarrett Billingsley, el 1 de marzo a las 11:07 me escribiste:On Sat, Feb 28, 2009 at 11:46 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:It will be nice not to use a keyword starting with "__" for a standard feature either because that prefix has a long history of being used for vendor-specific extensions (not to mention its awfulness =) -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- Do not get mad with others Because they know more than you It is not their fault:P I wasn't whining about it, I'd just rather not see a fifth method of compile-time introspection.Will it be implemented through __traits, or *yet another* compile-time introspection facility?Whatever it'll be, I'm sure it will not shut off your whine noise generator :o).
Mar 02 2009
Andrei Alexandrescu wrote:Edward Diener wrote:The whole debate about "compile-time" and "run-time" reflection is irrelevant as long as one can invoke it without having to inject code into an already existing construct. It must work through run-time code which can ask such reflection questions as: enumerate for me all of the classes in a particular module etc., or enumerate for me all the functions in a class etc. . It must work by allowing code from outside of a construct to query that construct and get its accessible constructs. How that run-time code is written, whether using "compile-time" reflection using templates, or run-time classes accessible from a library whose reflection data is produced by the D compiler, is not important from the user's point of view as long as the user has the access he wants and can write relatively clean and clear code to get it. Of course from within any given construct one should also be able to write code in a clear manner which accesses the inner constructs. Access to constructs via reflection should follow the same protection features as any other code, so that public constructs are always accessible but private constructs are only accessible following their normal rules. So I do not know what you mean by "only run-time reflection only is missing the point" but certainly the ability to use reflection at run-time is vitally important from outside of a construct to any 3rd party tool which wants to introspect already existing constructs and create objects from those constructs based on the information run-time reflection can return.I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point.
Feb 28 2009
Edward Diener wrote:Andrei Alexandrescu wrote:This is a long discussion, but in brief any runtime reflection engine needs some sort of compile-time metadata infrastructure. Some languages don't make that accessible within the language itself. Runtime reflection has been explored extensively, its possibilities and limitations are pretty well understood, I hardly smothered a yawn reading all you wrote. Compile-time reflection is much less understood and hides many more exciting possibilities. With the advances in compiler technology implemented by Walter, we have a chance to tackle reflection in a systematic manner. AndreiEdward Diener wrote:The whole debate about "compile-time" and "run-time" reflection is irrelevant as long as one can invoke it without having to inject code into an already existing construct. It must work through run-time code which can ask such reflection questions as: enumerate for me all of the classes in a particular module etc., or enumerate for me all the functions in a class etc. . It must work by allowing code from outside of a construct to query that construct and get its accessible constructs. How that run-time code is written, whether using "compile-time" reflection using templates, or run-time classes accessible from a library whose reflection data is produced by the D compiler, is not important from the user's point of view as long as the user has the access he wants and can write relatively clean and clear code to get it. Of course from within any given construct one should also be able to write code in a clear manner which accesses the inner constructs. Access to constructs via reflection should follow the same protection features as any other code, so that public constructs are always accessible but private constructs are only accessible following their normal rules. So I do not know what you mean by "only run-time reflection only is missing the point" but certainly the ability to use reflection at run-time is vitally important from outside of a construct to any 3rd party tool which wants to introspect already existing constructs and create objects from those constructs based on the information run-time reflection can return.I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point.
Feb 28 2009
Andrei Alexandrescu wrote:Edward Diener wrote:It was written because I have inevitably seen discussions about language reflection mechanisms end with talk about really neat new compile-time facilities which bring one no closer to real run-time reflection than before.Andrei Alexandrescu wrote:This is a long discussion, but in brief any runtime reflection engine needs some sort of compile-time metadata infrastructure. Some languages don't make that accessible within the language itself. Runtime reflection has been explored extensively, its possibilities and limitations are pretty well understood, I hardly smothered a yawn reading all you wrote.Edward Diener wrote:The whole debate about "compile-time" and "run-time" reflection is irrelevant as long as one can invoke it without having to inject code into an already existing construct. It must work through run-time code which can ask such reflection questions as: enumerate for me all of the classes in a particular module etc., or enumerate for me all the functions in a class etc. . It must work by allowing code from outside of a construct to query that construct and get its accessible constructs. How that run-time code is written, whether using "compile-time" reflection using templates, or run-time classes accessible from a library whose reflection data is produced by the D compiler, is not important from the user's point of view as long as the user has the access he wants and can write relatively clean and clear code to get it. Of course from within any given construct one should also be able to write code in a clear manner which accesses the inner constructs. Access to constructs via reflection should follow the same protection features as any other code, so that public constructs are always accessible but private constructs are only accessible following their normal rules. So I do not know what you mean by "only run-time reflection only is missing the point" but certainly the ability to use reflection at run-time is vitally important from outside of a construct to any 3rd party tool which wants to introspect already existing constructs and create objects from those constructs based on the information run-time reflection can return.I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.D2 will have reflection. (Walter doesn't know yet. He thinks D3 will have reflection.) It will be compile-time reflection because only run-time reflection only is missing the point.Compile-time reflection is much less understood and hides many more exciting possibilities. With the advances in compiler technology implemented by Walter, we have a chance to tackle reflection in a systematic manner.Good ! I look forward to seeing it and using it in D.
Mar 01 2009
Edward Diener wrote:I argued for this in the past on this NG but still no one seems to have picked up the idea that a full reflection library for D, supported fully by the compiler, would be a great thing. It would also allow RAD programming with D outside of the functionality one could use in 3rd party tools designed around full run-time reflection capabilities.I believe it is a great idea, it's just that there are so many that I'm swamped.
Feb 28 2009
On Sat, 28 Feb 2009 23:39:41 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Nick Sabalausky wrote:Yes. When writing a recursive function, it is often desired to have a way to call the function recursively via some shortcut, something like 'fthis' (this function). It would be great to have something like this in D. That way _FUNCTION__ could be replaced by 'fthis.stringof' or something similar. It also gives small other advantages (easier code refactoring etc). Here is an example: int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return fthis(c - 1) * c; }"dsimcha" <dsimcha yahoo.com> wrote in message news:goc1k7$qml$1 digitalmars.com...I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articlevoid foofunc() { Stdout.formatln("{}", __FUNCTION__); } Output: foofunc Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways.Can we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.Also, I'd like to be able to do something like: Reflect.invoke(__FUNCTION__, params);Yah... and Variant needs to have something similar as well. We know quite what std.reflect needs to look like, just we want to keep our fingers out of too many pies at once.Something funtionally equiveilent to that would aid maitenance of self-invoking functions (not only recusion, but also func overloads that are defined in terms of one "primary" overload). Also would be nice for similar reasons: __CLASS__ (or something similar that would also work for structs)Yah. Andrei
Feb 28 2009
Denis Koroskin wrote:On Sat, 28 Feb 2009 23:39:41 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:"fthis" does not sounds like a nice keyword. How about "self"?Nick Sabalausky wrote:Yes. When writing a recursive function, it is often desired to have a way to call the function recursively via some shortcut, something like 'fthis' (this function). It would be great to have something like this in D. That way _FUNCTION__ could be replaced by 'fthis.stringof' or something similar. It also gives small other advantages (easier code refactoring etc). Here is an example: int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return fthis(c - 1) * c; }"dsimcha" <dsimcha yahoo.com> wrote in message news:goc1k7$qml$1 digitalmars.com...I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articlevoid foofunc() { Stdout.formatln("{}", __FUNCTION__); } Output: foofunc Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways.Can we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.Also, I'd like to be able to do something like: Reflect.invoke(__FUNCTION__, params);Yah... and Variant needs to have something similar as well. We know quite what std.reflect needs to look like, just we want to keep our fingers out of too many pies at once.Something funtionally equiveilent to that would aid maitenance of self-invoking functions (not only recusion, but also func overloads that are defined in terms of one "primary" overload). Also would be nice for similar reasons: __CLASS__ (or something similar that would also work for structs)Yah. Andrei
Feb 28 2009
Johan Granberg wrote:Denis Koroskin wrote:We better use "..". int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return ..(c - 1) * c; } AndreiOn Sat, 28 Feb 2009 23:39:41 +0300, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:"fthis" does not sounds like a nice keyword. How about "self"?Nick Sabalausky wrote:Yes. When writing a recursive function, it is often desired to have a way to call the function recursively via some shortcut, something like 'fthis' (this function). It would be great to have something like this in D. That way _FUNCTION__ could be replaced by 'fthis.stringof' or something similar. It also gives small other advantages (easier code refactoring etc). Here is an example: int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return fthis(c - 1) * c; }"dsimcha" <dsimcha yahoo.com> wrote in message news:goc1k7$qml$1 digitalmars.com...I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility.== Quote from Jarrett Billingsley (jarrett.billingsley gmail.com)'s articlevoid foofunc() { Stdout.formatln("{}", __FUNCTION__); } Output: foofunc Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways.Can we get this please? It's so simple and would be terribly useful.Can someone explain what __FUNCTION__ would do in a little more detail? I feel like the two posts of this thread so far are talking in secret __FUNCTION__-dealer code.Also, I'd like to be able to do something like: Reflect.invoke(__FUNCTION__, params);Yah... and Variant needs to have something similar as well. We know quite what std.reflect needs to look like, just we want to keep our fingers out of too many pies at once.Something funtionally equiveilent to that would aid maitenance of self-invoking functions (not only recusion, but also func overloads that are defined in terms of one "primary" overload). Also would be nice for similar reasons: __CLASS__ (or something similar that would also work for structs)Yah. Andrei
Feb 28 2009
On Sat, Feb 28, 2009 at 4:50 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:We better use "..". =A0int factorial(int c) =A0{ =A0 =A0 //writefln(fthis.stringof); =A0 =A0 //writefln(typeof(fthis).stringof); =A0 =A0 if (c < 2) return 1; =A0 =A0 return ..(c - 1) * c; =A0}I hope this is a sarcastic reply :P
Feb 28 2009
Jarrett Billingsley wrote:On Sat, Feb 28, 2009 at 4:50 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:My second. I was afraid the first one wasn't transparent enough. AndreiWe better use "..". int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return ..(c - 1) * c; }I hope this is a sarcastic reply :P
Feb 28 2009
Andrei Alexandrescu escribió:Jarrett Billingsley wrote:The contextual keyword iota, right?On Sat, Feb 28, 2009 at 4:50 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:My second. I was afraid the first one wasn't transparent enough.We better use "..". int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return ..(c - 1) * c; }I hope this is a sarcastic reply :PAndrei
Feb 28 2009
Ary Borenszweig wrote:Andrei Alexandrescu escribió:That's the one! I think it even got a serious answer :o). AndreiJarrett Billingsley wrote:The contextual keyword iota, right?On Sat, Feb 28, 2009 at 4:50 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:My second. I was afraid the first one wasn't transparent enough.We better use "..". int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return ..(c - 1) * c; }I hope this is a sarcastic reply :P
Feb 28 2009
Andrei Alexandrescu wrote:Ary Borenszweig wrote:Sarcasm starts working against the author if less than 25% of the audience recognize it. --anonAndrei Alexandrescu escribió:That's the one! I think it even got a serious answer :o).Jarrett Billingsley wrote:The contextual keyword iota, right?On Sat, Feb 28, 2009 at 4:50 PM, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:My second. I was afraid the first one wasn't transparent enough.We better use "..". int factorial(int c) { //writefln(fthis.stringof); //writefln(typeof(fthis).stringof); if (c < 2) return 1; return ..(c - 1) * c; }I hope this is a sarcastic reply :P
Mar 01 2009
On Sat, 28 Feb 2009 12:30:35 -0500, Jarrett Billingsley wrote:Can we get this please? It's so simple and would be terribly useful.void foo() { writefln(__FUNCTION__); } void foo(int x) { writefln(__FUNCTION__); } ------------------- module bar; void foo() { writefln(__FUNCTION__); } ---------------- class One { void foo() { writefln(__FUNCTION__); } } struct Two { void foo() { writefln(__FUNCTION__); } } -------------- Any problems so far? -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Feb 28 2009
On Sat, Feb 28, 2009 at 5:24 PM, Derek Parnell <derek psych.ward> wrote:On Sat, 28 Feb 2009 12:30:35 -0500, Jarrett Billingsley wrote:I mentioned in a follow-up post that it would probably have to give a fully-qualified name in the presence of multiple modules and nesting and such. As for multiple overloads - so what? All I want is the name of the function.Can we get this please? =A0It's so simple and would be terribly useful.void foo() { =A0 =A0writefln(__FUNCTION__); } void foo(int x) { =A0 =A0writefln(__FUNCTION__); } ------------------- module bar; void foo() { =A0 =A0writefln(__FUNCTION__); } ---------------- class One { =A0void foo() =A0{ =A0 =A0 writefln(__FUNCTION__); =A0} } struct Two { =A0void foo() =A0{ =A0 =A0 writefln(__FUNCTION__); =A0} } -------------- Any problems so far?
Feb 28 2009
On Sat, 28 Feb 2009 17:27:27 -0500, Jarrett Billingsley wrote:On Sat, Feb 28, 2009 at 5:24 PM, Derek Parnell <derek psych.ward> wrote:void foo() { Â Â writefln(__FUNCTION__); } void foo(int x) { Â Â writefln(__FUNCTION__); }I mentioned in a follow-up post that it would probably have to give a fully-qualified name in the presence of multiple modules and nesting and such.Ah yes, I read that now ... {note to self: Should read all posts before replying :-)}As for multiple overloads - so what? All I want is the name of the function.But why? There could be conceivable circumstances in which one needed to know *which* 'foo' issued the message, one might need finer or more details to know that. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Feb 28 2009
On Sat, Feb 28, 2009 at 5:35 PM, Derek Parnell <derek psych.ward> wrote:lsAs for multiple overloads - so what? =A0All I want is the name of the function.But why? There could be conceivable circumstances in which one needed to know *which* 'foo' issued the message, one might need finer or more detai=to know that.Then, as Andrei suggested, we need a more flexible and fine-grained reflection mechanism. :)
Feb 28 2009
On Sat, 28 Feb 2009 17:42:55 -0500, Jarrett Billingsley wrote:Then, as Andrei suggested, we need a more flexible and fine-grained reflection mechanism. :)Agreed, but are you also suggesting that a simple __FUNCTION__ should also exist? By the way, my fear for D is that it is turning into an ASCII version of APL. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Feb 28 2009
Derek Parnell wrote:On Sat, 28 Feb 2009 17:42:55 -0500, Jarrett Billingsley wrote:I don't know much about APL, what was wrong with it? AndreiThen, as Andrei suggested, we need a more flexible and fine-grained reflection mechanism. :)Agreed, but are you also suggesting that a simple __FUNCTION__ should also exist? By the way, my fear for D is that it is turning into an ASCII version of APL.
Feb 28 2009
Andrei Alexandrescu wrote:I don't know much about APL, what was wrong with it?It needed a special keyboard.
Feb 28 2009
Walter Bright wrote:Andrei Alexandrescu wrote:There is an input method for APL that supports standard keyboards, I believe.I don't know much about APL, what was wrong with it?It needed a special keyboard.
Feb 28 2009
Christopher Wright wrote:Walter Bright wrote:Yeah, many kludge-o-matic workarounds have appeared over the years, none of which are very satisfactory.Andrei Alexandrescu wrote:There is an input method for APL that supports standard keyboards, I believe.I don't know much about APL, what was wrong with it?It needed a special keyboard.
Feb 28 2009
Andrei Alexandrescu wrote:Derek Parnell wrote:Plenty. It was a write-only language, on a par with brainf**ck. I've known guru-level apl programmers who regularly couldn't read their own code the next week. It's probably the most concise way of writing heavy and ultra efficient data manipulation code. It's a bit like spending a week writing an 80-character hairy regexp, and later trying to figure out how the heck it actually works. ---- But I think some of us should stick with D1.On Sat, 28 Feb 2009 17:42:55 -0500, Jarrett Billingsley wrote:I don't know much about APL, what was wrong with it?Then, as Andrei suggested, we need a more flexible and fine-grained reflection mechanism. :)Agreed, but are you also suggesting that a simple __FUNCTION__ should also exist? By the way, my fear for D is that it is turning into an ASCII version of APL.
Mar 01 2009
Andrei Alexandrescu:That's the one! I think it even got a serious answer :o).I'll try to put some humorous answers of this kind in my posts too, it will surely improve global clarity of the mailing list :-) Bye, bearophile
Feb 28 2009