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

Re^3: Sigils in Perl 6

by ysth (Canon)
on May 15, 2007 at 16:53 UTC ( [id://615586]=note: print w/replies, xml ) Need Help??


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

For those as clueless as me: twigil

Replies are listed 'Best First'.
Re^4: Sigils in Perl 6
by TimToady (Parson) on May 15, 2007 at 18:55 UTC
    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__.

      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.
      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://615586]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found