Nathan Torkington writes:
> 5) There's no equivalent to sub {FOO} where FOO is compiled at
> compile-time.  create_function() takes a string that's compiled at
> run-time.  The reliance on runtime eval() makes for fragile dangerous
> code.  They aren't even real anonymous functions--they have names,
> it's like gensym().

Just to clarify, I'm talking about anonymous subroutines here.

  $x = sub { print "hello, world" };  # Perl

becomes

  $x = create_function('', 'echo "hello, world"'); // PHP

Notice the quotes around the second argument.  I haven't found a way
to build an anonymous function that doesn't revolve around eval().

I'd like someone to take my list, and Andy's comments about separation
of function from form, and create a "Perl or PHP?" FAQ that can go on
perl.org.  Any volunteers?

Nat

Reply via email to