in reply to Re: variables names used to define variables
in thread variables names used to define variables

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

  • Comment on Re: variables names used to define variables

Replies are listed 'Best First'.
Re: Re: variables names used to define variables
by BrowserUk (Patriarch) on Dec 11, 2003 at 16:57 UTC
    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!

Re: Re: variables names used to define variables
by hardburn (Abbot) on Dec 11, 2003 at 17:02 UTC

    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

        Although this might be splitting hairs, the Blue Camel disagrees (p. 313):

        Although you're using the name of the method to invoke it indirectly, this usage is not forbidden by use strict 'refs', since all method calls are in fact looked up symbolically at the time they're resolved.

        Unless the author of that passage (Tom Christiansen, I think) also considers hash lookups to be symbolic.

        ----
        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

Re^3: variables names used to define variables
by Aristotle (Chancellor) on Dec 11, 2003 at 17:24 UTC
    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)->();
        So you've replaced the symbolic lookup of $sub by a symbolic lookup of "can", which, if it reaches UNIVERSAL::can, results in a symbolic lookup for $sub. And now?

        Makeshifts last the longest.