develooper Front page | perl.advocacy | Postings from August 2001

Re: My list of PHP's shortcomings

Thread Previous
Nathan Torkington
August 22, 2001 06:34
Re: My list of PHP's shortcomings
Message ID:
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


  $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  Any volunteers?


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About