rationale for function and delegate
klickverbot
see at klickverbot.at
Sat Oct 16 02:07:08 PDT 2010
On 10/16/10 10:40 AM, Paulo Pinto wrote:
> while reading TDPL I start wondering what is the background between function
> and delegate.
delegate() is a function pointer amended with a second context pointer,
which allows you to have pointers to member functions, closures and so on.
function() is a C-style function pointer and can be used to interface
with C code, etc., but obviously not for closures, since it its lacking
the context part.
There is a clear difference between the two types, Ilthough you probably
don't need raw function pointers very often if you are working in a D
only environment. If you want to have the compiler decide, you could
always use auto…
More information about the Digitalmars-d
mailing list