in reply to Builtin functions defaulting to $_

Some things in this list might change in 5.10 (at least mkdir() will). Who knows when that might come out tho :)

Replies are listed 'Best First'.
Re^2: Builtin functions defaulting to $_
by TimToady (Parson) on Mar 24, 2007 at 02:14 UTC
    The list will certainly change for Perl 6, insofar as it will be an empty list. If you want to default a function call to $_ you use the "unary dot" form:
    for 1..10 { .say }
    Of course, pattern matching and topicalizers still implicitly deal with $_, but you no longer have to memorize a long list of functions, nor worry about the difference between
    rand > 0.5 # means rand($_) > 0.5 rand < 0.5 # parse error looking for fileglob
    since in Perl 6 that is unambiguously
    .rand < 0.5 # always means rand($_) < 0.5
    You don't have to memorize which symbols are true globals either. As for Perl 5's magical use of $a and $b, the less said the better... :-)
      You don't have to memorize which symbols are true globals either.
      which will relieve a lot of grief. Like with $! and $@ which may get overwritten if not dealt with in a timely manner. If I well remember, $! will be just a reference to what the current error looks like; therefore the question: what's $@ in Perl 6, if it exists at all? I could think of that as a list of messages of what things blew up from there to here (ie some "exception stack trace excerpt") - but then, that would be more appropriately @$! (in perl5 syntax, that is)...

      update: reading again, not "have(ing) to memorize which symbols are true globals" means: there are no true global symbols, right?

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        There is no $@ in Perl 6; all errors are unified into the $! object, which can hold all the info it needs to. And in general, those few remaining punctuational variables are all lexically scoped.

        But what I meant was that you don't have to remember that names like STDIN and ARGV are the same symbol in every package. Those are now spelled $*IN and @*ARGS, where the * indicates true global scope; or perhaps just membership in the GLOBAL package, which as you point out arguably means there are no true globals.