Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Anyway, after compile-time the calls to the functions are already bound in the code and the actual symbol table entries aren't needed anymore.

    I don't buy it:

    $ perl -MO=Concise,new
    sub double {
        my $number = shift;
        return $number * 2;

    sub new {
        my ($class, $number) = @_;
        bless {number => double($number)}, $class;

    k  <1> leavesub[1 ref] K/REFC,1 ->(end)
    -     <@> lineseq KP ->k

    • Hrm, point for you. Bad wording on my side. What's the thing called methods are looked up from then? :)

      I honestly thought a delete $Foo::{bar} will remove the symbol table entry.

      Thanks again!

      Ordinary morality is for ordinary people. -- Aleister Crowley
      • You misunderstood what chromatic said. He demonstrated that Perl does not have compile-time binding, contrary to what you are saying. Decompiling shows that the invocation of double in the new method is indirected via the package. If you remove the entry for double from the package, the function call will NOT work.

        Sorry, but your approach won’t work.

        Here’s a pattern for you to read carefully and chew on:

        package Foo::Bar::Internals;

        use Carp qw( croak );

        sub double { ... }

        sub Foo::Bar::new

        • So, you're saying what? I can understand that as either

          • Bad wording on my side, and it's not removed from the symbol table, but from some other table used for method lookups.
          • I'm doing voodoo, because the things I do in the test cases can't work.

          And btw: You call that a pattern? I call that a work-around :) And, just FYI, you might want to stay away from patronising phrases like "Here’s a pattern for you to read carefully and chew on." Because it really decreases my motivation to answer.

          Ordinary morality is for ordinary people. -- Aleister Crowley
          • You said:

            So, you’re saying what?

            It’s bad wording on your part to say the functions are bound in the code, because they’re not; they’re always looked up from the symbol table.

            Interestingly, what you’re doing shouldn’t work – but it does! Apparently the %main::-type hashes aren’t actually an interface to the symbol table, they’re just a one-way mirror:

            sub xx {
                my $in_stbl = *main::foo{CODE} ? 1 : 0;
                my $in_hash = main-