Is there a way for a function to return itself in D?
schveiguy at yahoo.com
Tue Oct 14 09:01:16 PDT 2008
"Simen Kjaeraas" <simen.kjaras at gmail.com> wrote in message
news:op.ui0ff1np1hx7vj at biotronic.osir.hihm.no...
> Like the subject says, I wonder if it's possible for a function to return
> No matter how I think of this, I end up with an endless recursive function
> declaration. Creating a functor that does this is simple, so why not a
Nope. Because the type of the function must include all the functions you
function(int x) function(int x)
is a different type than
function(int x) function(int x) function(int x)
For a functor it's simple. You are not returning a function, but a pointer
to a possibly not fully-defined object, so the type does not need to be
fully specified before it is used.
You would need to be able to declare a function type before defining it in
order to be able to do this.
More information about the Digitalmars-d-learn