February 28, 2009 __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Can we get this please? It's so simple and would be terribly useful. | ||||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Hello Jarrett,
> Can we get this please? It's so simple and would be terribly useful.
>
++vote;
| |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | == Quote from Jarrett Billingsley (jarrett.billingsley@gmail.com)'s article > 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. | |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS | "BCS" <none@anon.com> wrote in message news:a6268ff30f38cb67a8ee93108e@news.digitalmars.com... > Hello Jarrett, > >> Can we get this please? It's so simple and would be terribly useful. >> > > ++vote; > repeat(1, BCS_comment()); | |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to dsimcha | "dsimcha" <dsimcha@yahoo.com> wrote in message news:goc1k7$qml$1@digitalmars.com... > == Quote from Jarrett Billingsley (jarrett.billingsley@gmail.com)'s article >> 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. void 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) | |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | On Sat, Feb 28, 2009 at 2:15 PM, Nick Sabalausky <a@a.a> wrote:
>
> void foofunc()
> {
> Stdout.formatln("{}", __FUNCTION__);
> }
>
> Output:
> foofunc
It would probably be the fully-qualified name, especially when you consider using it for reflection.
| |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | Nick Sabalausky wrote: > "dsimcha" <dsimcha@yahoo.com> wrote in message news:goc1k7$qml$1@digitalmars.com... >> == Quote from Jarrett Billingsley (jarrett.billingsley@gmail.com)'s article >>> 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. > > void foofunc() > { > Stdout.formatln("{}", __FUNCTION__); > } > > Output: > foofunc > > Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways. I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility. > 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 | |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Hello Andrei,
> Nick Sabalausky wrote:
>
>> Stdout.formatln("{}", __FUNCTION__);
>
> I think instead of __FUNCTION__ we'll define a much more comprehensive
> static reflection facility.
>
for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.
| |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote:
> Hello Andrei,
>
>> Nick Sabalausky wrote:
>>
>>> Stdout.formatln("{}", __FUNCTION__);
>>
>> I think instead of __FUNCTION__ we'll define a much more comprehensive
>> static reflection facility.
>>
>
> for the above case I think __FUNCTION__ is as good as it will get. Define it as a human readable identifier rather than reflection.
>
>
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.
Andrei
| |||
February 28, 2009 Re: __FUNCTION__ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sat, 28 Feb 2009 23:39:41 +0300, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: > Nick Sabalausky wrote: >> "dsimcha" <dsimcha@yahoo.com> wrote in message news:goc1k7$qml$1@digitalmars.com... >>> == Quote from Jarrett Billingsley (jarrett.billingsley@gmail.com)'s article >>>> 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. >> void foofunc() >> { >> Stdout.formatln("{}", __FUNCTION__); >> } >> Output: >> foofunc >> Ie, basically the same as __FILE__ and __LINE__ and useful in the same ways. > > I think instead of __FUNCTION__ we'll define a much more comprehensive static reflection facility. > >> 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 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; } | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply