Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Perl6: S2 identifier and $ special var questions

by PrakashK (Pilgrim)
on Sep 14, 2011 at 15:56 UTC ( #925940=note: print w/replies, xml ) Need Help??

in reply to Perl6: S2 identifier and $ special var questions

In S02 synopsis, section "Names and Variables", I see:

$<foo> match variable, short for $/{'foo'}

So, when you say my $<-var>;, you are actually initializing the key -var of the hash $/.

Here's what I see in recent rakudo:

>> perl6 -v This is Rakudo Perl 6, version 2011.07-2-g1b7dd12 built on parrot 3.6. +0 RELEASE_3_6_0 >> perl6 > my $<-var> = 42 42 > $/ -var 42 > $/.WHAT Hash()

Replies are listed 'Best First'.
Re^2: Perl6: S2 identifier and $ special var questions
by rir (Vicar) on Sep 14, 2011 at 17:26 UTC
    Thanks, the code is explained.

    How would I declare and use $MyClass::-O'malley's as indicated by the quoted spec?

    Be well,

      You may not start an identifier with - like that; hyphens and apostrophes are only allowed internally.

      In theory one can declare or use any name you like using Perl 6's explicit symbolic ref notation:

      my $::("-O'Malley's") = 42; say $::("-O'Malley's");
      However, neither implementation does constant folding well enough yet to recognize these as a static variable names.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925940]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2016-10-22 12:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.