in reply to Re: Here's a quick example why not to use Indirect notation
in thread Perl High School

Interesting! Anyone want to explain why this works??

However, the syntax looks horrible. You have parentheses, indicating a function or method name, on a token indicating a package name. This looks to be a very poor design decision, in my opinion.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

  • Comment on Re: Re: Here's a quick example why not to use Indirect notation

Replies are listed 'Best First'.
Re: Re: Re: Here's a quick example why not to use Indirect notation
by dws (Chancellor) on Feb 22, 2002 at 18:50 UTC
    However, the syntax looks horrible. You have parentheses, indicating a function or method name, on a token indicating a package name. This looks to be a very poor design decision, in my opinion.

    Try approaching this from the perspective of creating an instance of a Class, rather than invoking a method in a package. Perl doesn't have constructors, but you can simulate the effect. I do this for expressive purposes.

      In addition, if you mistype the name, so say you do something like:
      package Foo; sub new { return bless {}, shift; } -------- use Foo; my $bar = new FOO();
      You get an error saying that main::FOO() could not be found. That's not a good error.

      Direct notation is put there for a purpose. I think that indirect notation was a bad idea all around, put in to pander to another community that looks down on Perl usage to begin with. *shrugs*

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        In addition, if you mistype the name ... you get an error saying that main::FOO() could not be found. That's not a good error.

        That's a rare problem (depending on one's typing skills) that takes, what, about 30 seconds to resolve?