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

Re: My list of PHP's shortcomings

Thread Previous
From:
Nathan Torkington
Date:
August 22, 2001 06:34
Subject:
Re: My list of PHP's shortcomings
Message ID:
15235.46237.104000.83431@gargle.gargle.HOWL
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


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About