in reply to Re: Re: Re: Re^4: Perl6 syntax being too much complex? How we will teach and read that?!
in thread Perl6 syntax being too much complex? How we will teach and read that?!

Well, everything's an object underneath if you scratch it, so whether $nonrefscalar.elems returns an error probably depends on how $nonrefscalar is "tied" as a container object, to use the Perl 5 term. In general it's probably an error for the default implementation of scalars. Possibly it should return an undef containing an unthrown exception. Either that, or it should always return 1. :-)

The parens are not necessary for an indirect object, which your colon forces it to be. Chances are it'll even work without the colon, because the syntactic function of the colon is to separate the indirect invocant from its arguments, and if there are no arguments, it's not ambiguous. It's only with arguments that the colon becomes obligatory.

Basically, the dispatch rules are defined such that, for argumentless methods, it doesn't matter whether you call them as methods or subroutines--you end up at the same place. So you don't have to care whether

close $handle;
is defined as a global, multi-dispatched subroutine or as a normal method on filehandles.
  • Comment on Re: Re: Re: Re: Re^4: Perl6 syntax being too much complex? How we will teach and read that?!
  • Select or Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re^4: Perl6 syntax being too much complex? How we will teach and read that?!
by BrowserUk (Patriarch) on Mar 25, 2004 at 18:21 UTC
    Well, everything's an object underneath if you scratch it,...

    That begs one more question, but I'll understand if it's too early for a difinitive answer:

    Is my $sub = { .... }; a private subroutine declaration? (And are while/map/reduce etc. methods of a code object?)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
      That's two questions... :-)

      I would not call that a private subroutine declaration, but an anonymous subroutine stored in a private variable. You can already do the same thing in Perl 5, except you have to say "sub" explicitly. But if you want a private sub, either of

      my &foo = {...}; my sub foo {...}
      will work.

      As for your second question, in general we'll try not to hang specialized methods off of generic classes unless they really belong. Most of these things are multi-dispatched global subs instead. (And while is probably hard-wired in the interests of giving the optimizer as much information as possible, so that it can cheat on control exceptions like "next".)