Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: MOPT-04 - identification, part 2

by adrianh (Chancellor)
on Jan 07, 2003 at 17:34 UTC ( #225030=note: print w/replies, xml ) Need Help??


in reply to MOPT-04 - identification, part 2

Perl's function bindings are statically scoped, not dynamically scoped, so we can't bind the name to a new entity in a different evaluation context.

You can, of course, do:

sub func { return "original value.\n" } sub print_func { print func(), " "; } sub redefine_func { local *func = sub { return ("local value.\n") }; print_func(); }

Which is still binding an identifier to an entity by your definitions (I think :-)

Replies are listed 'Best First'.
Re2: MOPT-04 - identification, part 2
by mstone (Deacon) on Jan 08, 2003 at 01:59 UTC

    well darned if you aren't right..

    The syntax you used does exactly the same thing as a standard function definition, except it does it locally. By all rights, defining a function with a name should be syntactic sugar for assigning an anonymous subroutine to a typeglob. Apparently it isn't, and I missed it.

    Bravo.. I stand corrected. And so does the article.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://225030]
help
Chatterbox?
[marto]: yep :)
[Discipulus]: being her marto, can you explain what "Par for the course I'm afraid." means?
Discipulus here..
[marto]: "what is normal or expected in any given circumstances."
[marto]: better: "If a type of behaviour, event, or situation is par for the course, it is not good but it is normal or as you would expect"
[Discipulus]: thanks i was unable to decide where to split the sentece
[marto]: FWIW search.cpan rarely has issues, see http://noc.perl. org for a route to report problems
[oakbox]: thanks, marto.
[marto]: there was a period where search.cpan had some frequent outages for (IIRC) a couple of weeks. I've not had any problems since, until today.
[marto]: this was about 16 months ago maybe. the noc team are, in my experience, very responsive to reports of issues, so please raise the issue after checking known problems/outages

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-07-26 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (388 votes). Check out past polls.