[DGD] function pointers

Noah Gibbs noah_gibbs at yahoo.com
Fri Jun 24 15:07:51 CEST 2011


  The other thing "function pointer"-type objects are used for in higher-level languages is for more interesting second-order functions -- map and reduce, currying, and in the far extreme, LISP macros.  As Felix has shown here, you can pretty quickly do things like map/reduce and currying using object and method names, without *too* much more effort than the higher-level language equivalent structures, and with better performance than most (Haskell excepted - but Haskell pays heavily in transparency for its combination of extreme abstraction and compiled speed).

  But things like LISP macros?  A tricky question in any non-LISP language.  DGD, however, has a nice little DGD-parsing grammar available, and hooks to run before files are compiled.  That's less elegant than the LISP or Ruby solutions to the problem, but it's also more scalable, simpler to implement and debug, and much faster to execute.

  A good tradeoff for a language at LPC's/DGD's abstraction level.


________________________________
From: Felix A. Croes <felix at dworkin.nl>
To: dgd at dworkin.nl
Sent: Friday, June 24, 2011 1:54 PM
Subject: Re: [DGD] function pointers

Jared Maddox <absinthdraco at gmail.com> wrote:

>[...]
> If you don't think they belong in LPC, then what would you normally
> use instead? An object-based solution? Call-by-name? I agree that this
> isn't important, but it certainly IS convenient.

Under the hood, function pointers are implemented as an array holding
an object and a function name.  The fact that the implementation is so
trivial suggests that function pointers are not in any way essential.

In C, I find that I use function pointers only when I want to simulate
dynamic dispatch, which LPC already has because it is object-oriented.

Thus, I see function pointers in LPC as trivial on a low level of
abstraction, and superfluous on a high level.

Regards,
Felix Croes
___________________________________________
https://mail.dworkin.nl/mailman/listinfo/dgd


More information about the DGD mailing list