in reply to variables names used to define variables

Symobolic refs are there because Perl needs them for certain things to work. For instance, class/object method calls are always done symbolically (even under strict 'refs'). Also, there are some tricks you can do for making a bunch of accessors/mutators at once using symbolic refs (which also happens to save memory).

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: variables names used to define variables
by Abigail-II (Bishop) on Dec 11, 2003 at 16:00 UTC
    Symobolic refs are there because Perl needs them for certain things to work.
    The main reason symbolic refs are in Perl is that before perl5, symbolic refs were the only refs you had.
    For instance, class/object method calls are always done symbolically (even under strict 'refs').
    Bullshit. There are no references to subs involved in finding methods when it comes to class or object method calling. Walking the @ISA tree has nothing to do with references.

    Perhaps you are confused about exporting subs (which is typically not done by OO classes). But then you are wrong again. Most exporting is done via the Export module, which uses neither 'strict' nor 'warnings'.

    Abigail

      Bullshit.

      Come on, stopping pussy-footing around and say what you mean man.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Hooray!

      There are no references to subs involved in finding methods when it comes to class or object method calling.

      Yes there is. Otherwise, this code wouldn't work:

      $ perl -Mstrict -e ' package My::Foo; sub bar { my $class = shift; print "Calling $class->bar\n"; } package main; my $class = "My::Foo"; my $method = "bar"; $class->$method(); ' Calling My::Foo->bar $

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      : () { :|:& };:

      Note: All code is untested, unless otherwise stated

        That's no more a reference than
        my %hash; my $key = "foo"; $hash {$key} = 1;
        is.

        Abigail

      There are no references to subs involved in finding methods when it comes to class or object method calling.
      Not directly, but method invocation always involves symbol table lookups, which is just what a symref does.

      Makeshifts last the longest.

        ($sub =~ /^(.*)::/ ? $1 : __PACKAGE__)->can($sub)->();