in reply to Re: Re: $_ haters anonymou
in thread $_ haters anonymou

Says redcloud:
> Why is [${^_Ben_Tillys_Variable}] so much
> better than $main::Ben_Tillys_Variable?
That's a good question. It isn't that much better, but that wasn't the main point of the patch. The reason for the patch was that there are all these $^T, $^L, $^V, $^S variables already. They're all forced into package main::, which is what you want, because you don't want to have to say $main::^M everywhere. And we were starting to run out of letters! So I put the patch in so that the next time someone wants to make up a new feature and use a new $^M variable, they can call it ${^Emergency_Memory} instead. It will be forced into package main:: just like $^M is.

Since I was doing that anyway, I thought I might as well reserve some of those variables for the user, just in case they turned out to be useful for someone. If not, it's OK, because it didn't cost anything.

Replies are listed 'Best First'.
(cLive ;-) Re: $_ haters anonymou
by cLive ;-) (Prior) on Jan 25, 2002 at 04:16 UTC
    you don't want to have to say $main::^M everywhere.

    i blinked b4 replying, but you don't have to:

    $::^M is equivalent to $main::^M - 'main' is the default namespace.

    Or have I grabbed the wrong end of a pointy stick?

    cLive ;-)

      Says cLive ;-):
      $::^M is equivalent to $main::^M - 'main' is the default namespace.
      Actually they're both syntax errors.

      If they weren't syntax errors, then yes, the variable $::^M is identical to $main::^M. But not because main is the default namespace. It's because the empty stash name is interpreted as though you had said main instead. See line 579 of gv.c:

      if (!*name) return gv ? gv : (GV*)*hv_fetch(PL_defstash, "main::", + 6, TRUE);
      If the name turns out to have been empty, Perl looks up the main stash instead.

      --
      Mark Dominus
      Perl Paraphernalia