rationale for function and delegate
Paulo Pinto
pjmlp at progtools.org
Sat Oct 16 04:16:32 PDT 2010
Ah, ok that makes sense to me.
Although for other languages reason 1 is usually decided by the compiler,
but then again most
of the modern languages don't interface directly with C.
--
Paulo
"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
news:mailman.641.1287221213.858.digitalmars-d at puremagic.com...
> On Saturday 16 October 2010 01:40:55 Paulo Pinto wrote:
>> Hi,
>>
>> while reading TDPL I start wondering what is the background between
>> function and delegate.
>>
>> They seem to provide more or less the same funcionality, except delegate
>> allows the capture
>> of the function declaration environment.
>>
>> Most of the programming languages with support for closures only have one
>> way of doing it.
>>
>> Why is D providing two ways of doing it? For me sounds like a feature
>> similar to register, or
>> inline for doing what should be the compilers work. Deciding the best
>> implementation for the
>> closure.
>>
>> Thanks,
>> Paulo
>
> I believe that the two main reasons are
>
> 1. function pointers have less overhead.
>
> 2. If you want to use function pointers when calling C functions, you need
> function pointers rather than delegates.
>
> but there are probably others.
>
> - Jonathan M Davis
More information about the Digitalmars-d
mailing list