Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: Sigils in Perl 6

by TimToady (Parson)
on May 15, 2007 at 18:55 UTC ( [id://615619]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Sigils in Perl 6
in thread What's wrong with Perl 6?

And just to add something that is not explained at all in the synopsis, the idea of twigils is actually stolen straight from Ruby, which uses sigils to indicate strange scoping rather than data structure. A lovely idea, but using up sigils for that limits the extensibility of the mechanism, because there aren't that many ASCII symbols left to use in the sigil position that don't already mean something else. But by placing the scope indicator in the twigil position (that is, after a mandatory sigil), we can reserve the rest of the symbol keys on your keyboard to indicate future scopes that maybe haven't even been invented yet. Maybe someone will invent transaction scopes, for instance.

So I think of twigils as just another way of making Perl more like Perl. As with sigils, the primary purpose of twigils is to give you, the reader, a visual clue about what's going on in a bit of code without having to memorize every declaration surrounding this scope. The moment you see something like $?FOO you can know that it's a variable to the compiler but a constant to the compiled code, without having to memorize a list of special symbols, or use weird non-sigil conventions like __FOO__.

Replies are listed 'Best First'.
Re^5: Sigils in Perl 6
by ysth (Canon) on May 15, 2007 at 19:01 UTC
    So is ^ a perl5 twigil?
      So is ^ a perl5 twigil?
      Heh, kinda, except it's almost completely wasted on producing variable names consisting of control characters. The ^ twigil in Perl 6 is rather more useful, I'd like to think. How many times have people been bitten by magical $a and $b in Perl 5? The ^ twigil fixes that, and more. A goodly many of Perl 6's features can be explained as simply trying to make Perl 5's FAQs into former FAQs.
        Now I'm wondering when someone will write a YAPE::Regex::Explain-like module for perl 6 nouns :)
        How many times have people been bitten by magical $a and $b in Perl 5?

        While I'm a strong advocate of "do not use $a and $b as general purpose variables" myself, and I feel like having written so in hundreds of posts... to answer your question literally: "probably fewer than those who have been warned not to!"

Re^5: Sigils in Perl 6
by jplindstrom (Monsignor) on May 15, 2007 at 19:21 UTC
    But by placing the scope indicator in the twigil position (that is, after a mandatory sigil), we can reserve the rest of the symbol keys on your keyboard to indicate future scopes that maybe haven't even been invented yet.
    Would that mean new twigils can be introduced by application programmers? So, e.g. Catalyst::Controller::BindLex could use this instead of attributes?

    /J

      "All's fair if you predeclare" :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found