Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

(ichimunki) re x 2: Why are closures cool, continued?

by ichimunki (Priest)
on Jan 19, 2002 at 04:47 UTC ( #140018=note: print w/replies, xml ) Need Help??

in reply to Re: Why are closures cool, continued?
in thread Why are closures cool, continued?

Data::Dumper is going to give out "DUMMY" as the value for any sub, not just a closure. The contents of a subroutine are represented internally with a variety byte code I believe, which would look like so much nonsense if it were printed in the contents of a Data::Dumper dump. Contrast to scalars (or hash keys or hash/array values made from scalars) and to references. Scalars eventually turn out to be some sequence of characters, and references inside a data structure can be represented with brackets and braces.

'perldoc Data::Dumper' has more info on this in the BUGS section.
  • Comment on (ichimunki) re x 2: Why are closures cool, continued?

Replies are listed 'Best First'.
Re: (ichimunki) re x 2: Why are closures cool, continued?
by theorbtwo (Prior) on Jan 20, 2002 at 00:30 UTC

    As to "[t]he contents of a subroutine [being] represented internally with a variety [of] byte code", you're both right and wrong (as is so often the case when talking about internals). The internals do deal with coderefs as pointing to a bunch of bytecode, but that bytecode is not inherently serializable; it has lots of pointers in it. Moreover (without resorting to Devel:: or B:: modules), it isn't accessable with Perl code.

    The perl6 analog of Data::Dumper will be able to dump coderefs as Parrot assembler (pasm); one of the cool side-effects of going to an explicit VM.

    James Mastros,
    Just Another Perl Scribe

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://140018]
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2018-06-22 00:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.