## D - Recursive function literals?

• James Widman (9/9) Apr 22 2004 Is there any way to do it? If not, then I'm thinking, since "body" is
• Walter (3/12) Apr 22 2004 I think it would be better to just name it!
• C. Sauls (17/28) Apr 22 2004 I'm strange, but I like it. Then again I'm also of the opinion that
James Widman <james jwidman.com> writes:
Is there any way to do it? If not, then I'm thinking, since "body" is
already a keyword, you could just use that:

h(function int ( int i ) { if ( i == 0 ) return i;
return i + body( i-1);
});

If that becomes adopted, it might also be good to encourage the use of
"body" for recursions in general; it's like a big red flag that says "I
recurse!", which could be handy in functions so large that you
temporarily forget their names while reading them. ;-)
Apr 22 2004
"Walter" <walter digitalmars.com> writes:
I think it would be better to just name it!

"James Widman" <james jwidman.com> wrote in message
news:james-CD365A.13185322042004 digitalmars.com...
Is there any way to do it? If not, then I'm thinking, since "body" is
already a keyword, you could just use that:

h(function int ( int i ) { if ( i == 0 ) return i;
return i + body( i-1);
});

If that becomes adopted, it might also be good to encourage the use of
"body" for recursions in general; it's like a big red flag that says "I
recurse!", which could be handy in functions so large that you
temporarily forget their names while reading them. ;-)
Apr 22 2004
"C. Sauls" <ibisbasenji yahoo.com> writes:
I'm strange, but I like it.  Then again I'm also of the opinion that
there ought to be a 'pass()' statement for recursing into the
superclass.  A la:

class Foo {
int somefunc(int x) { ... }
}

class Bar {
override int somefunc(int x) {
if (x == SOME_SPECIAL_CASE)
// ... do stuff
pass(x); // used to be: super.somefunc(x)
}
}

I think pass() and body() would make nice siblings.

-C. Sauls
-Invironz

James Widman wrote:
Is there any way to do it? If not, then I'm thinking, since "body" is
already a keyword, you could just use that:

h(function int ( int i ) { if ( i == 0 ) return i;
return i + body( i-1);
});

If that becomes adopted, it might also be good to encourage the use of
"body" for recursions in general; it's like a big red flag that says "I
recurse!", which could be handy in functions so large that you
temporarily forget their names while reading them. ;-)
Apr 22 2004