Jump to page: 1 25  
Page
Thread overview
__FUNCTION__
Feb 28, 2009
BCS
Feb 28, 2009
Nick Sabalausky
Feb 28, 2009
dsimcha
Feb 28, 2009
Nick Sabalausky
Feb 28, 2009
BCS
Feb 28, 2009
grauzone
Mar 01, 2009
Christopher Wright
Mar 01, 2009
Christopher Wright
Feb 28, 2009
Nick Sabalausky
Mar 01, 2009
Edward Diener
Mar 02, 2009
Leandro Lucarella
Mar 01, 2009
Edward Diener
Mar 01, 2009
Edward Diener
Mar 01, 2009
Walter Bright
Feb 28, 2009
Denis Koroskin
Feb 28, 2009
Johan Granberg
Mar 01, 2009
Ary Borenszweig
Mar 01, 2009
Georg Wrede
Feb 28, 2009
Derek Parnell
Feb 28, 2009
Derek Parnell
Feb 28, 2009
Derek Parnell
Mar 01, 2009
Walter Bright
Mar 01, 2009
Christopher Wright
Mar 01, 2009
Walter Bright
Mar 01, 2009
Georg Wrede
February 28, 2009
Can we get this please?  It's so simple and would be terribly useful.
February 28, 2009
Hello Jarrett,

> Can we get this please?  It's so simple and would be terribly useful.
> 

++vote;


February 28, 2009
== 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
"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
"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
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
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
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
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
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;
}

« First   ‹ Prev
1 2 3 4 5