in reply to Re^4: input switch
in thread input switch

It's still doing a dispatch type of invocation. (so it's late bound) so at the lower levels, it's effectively the same as eval() to an extent -- you're still having to string comparison at runtime to check if the method exists, then invoking the late bound method, which naturally doesn't compile down as well as the early bound option which if...elsif... implies.

--
RatArsed

Replies are listed 'Best First'.
Re^6: input switch
by Aristotle (Chancellor) on Sep 09, 2002 at 12:41 UTC
    There's no early binding in Perl. All method calls are symbolic lookups at run time. That means the if elsif method does a dispatch as well as a string comparison. Which is what I already said in my first reply on this thread branch.

    Makeshifts last the longest.

      Oops, my bad, I didn't see that.

      does seem a bit counter intuative to use a late binding method when you already know the method name. I could defned my solution in so much that if it is implemented in the future, then you automatically get the benefits it brings...

      --
      RatArsed

        Seems counterintuitive, doesn't it? Unfortunately early binding simply isn't possible in Perl since a) you can add symbols to a package at runtime (think AUTOLOAD tricks) and b) @ISA can be modified anytime. Perl is in general a very highly dynamic language, but that comes at a price..

        Makeshifts last the longest.