Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Is Perl a good career move?

by thinker (Parson)
on May 24, 2005 at 15:46 UTC ( #460046=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Is Perl a good career move?
in thread Is Perl a good career move?

>> Functions created by create_functions are NAMED, not anonymous. In fact, create_function RETURNS the name.

Create function does indeed return a string, but does that mean it is not an anonymous function. perhaps we are concentrating too much on semantics here

The documentation for the function states " create_function -- Create an anonymous (lambda-style) function". Perhaps more semantics. Nevertheless, building a dispatch table from the result of create_function works for me.

I take on board your point about ||= for a function which has side effects

cheers

thinker


Comment on Re^5: Is Perl a good career move?
Re^6: Is Perl a good career move?
by Juerd (Abbot) on May 24, 2005 at 16:16 UTC

    The functions created by create_functions are named, not anonymous. The value returned by create_function is the name of the newly created function. This name begins with a nullbyte, but it is a global name anyhow. $foo = create_function(...); $foo(); works because $foo here is a symbolic reference. create_function uses eval and has many caveats. From PHP's source:

    sprintf(eval_code, "function " LAMBDA_TEMP_FUNCNAME "(%s){%s}", Z_STRV +AL_PP(z_function_args), Z_STRVAL_PP(z_function_code));
    The function has a name, and is thus not anonymous. PHP's documentation is outright false.

    Your dispatch table may work for you. But it is very inefficient and very ugly. You'd even be better off with a bunch of explicitly named functions and simple symbolic references. Back to square one of the programming mine field...

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://460046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-18 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (109 votes), past polls