in reply to I love anonymous functions!

I agree with you 100%, I love anonymous functions too. I first used them in Javascript actually. After that I fiddled with them in python, then I played with a number of functional langauges which all had similar concepts, and lastly I found perl and it was love at first type.

As for your Zork engine, C has function pointers, but I know they are not the same thing. But LISP can do anonymous functions for sure.

#'(lambda (args) (body))

-stvn

Replies are listed 'Best First'.
Re^2: I love anonymous functions!
by tilly (Archbishop) on Jul 01, 2004 at 01:27 UTC
    C's function pointers are not the same thing, but you can create a struct of a function pointer and a data pointer, and then you can create a function that calls that function with two arguments, the data in the struct and an additional pointer passed in.

    This construct can then be treated similarly to how you'd use an anonymous function in Perl. You'll have to do the equivalent of closures by stuffing information into the data pointer and then binding it inside the function.

    Alternately you can use Inline::Perl in CPR mode and then escape to actual Perl functions written in Perl wherever you want...