Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Why doesn't "my ($x) = @);" generate a syntax error?

by tobyink (Abbot)
on Jun 13, 2013 at 06:50 UTC ( #1038686=note: print w/replies, xml ) Need Help??


in reply to Why doesn't "my ($x) = @);" generate a syntax error?

For any punctuation character x, if there is a magic variable called $x, then there must also be magic variables called @x and %x. That's an artefact of how current versions of the Perl parser work. So because the $) exists and does something useful, the @) variable must also exist (even if it does nothing useful!)

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Why doesn't "my ($x) = @);" generate a syntax error?
by Grimy (Pilgrim) on Jun 13, 2013 at 17:57 UTC
    Correction: for any punctuation character x except '[' and '{', there exist global variables $x, @x and %x. Those variables are not necessarily magic, and their existence doesn't depend on the fact that $x does something useful. For example, none of $}, @} and %} are magic, yet they are all global variables.

      $[, @[ and %[ work (or at least they do in 5.18.0). If ${, @{ and %{ were to work, that would break dereferencing.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re^2: Why doesn't "my ($x) = @);" generate a syntax error?
by zork42 (Monk) on Jun 13, 2013 at 06:57 UTC
    I'd have never realised that.
    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038686]
help
Chatterbox?
[james28909]: there are all kinds of things that had to happen to let life come to be. but at the same time, life may not be the end goal IF there is any kind of end goal lol
[james28909]: well who is the person who gets to decide which behaviour is worthy of a downvote? a person with their own beliefs? xD
[erix]: teleology -- I've never understood why that was thunk up
[erix]: ( and when teleology was brought up, during my biology-study., I couldn't get an answer either )
[1nickt]: FTR I agree with you about "design." Just not sure about the trajectory of evolution. THere are a lot of dead-ends in the evolutionary paths. I suspect homo sapiens is just one of them.
[james28909]: thanks for the vid holli, i do like it. thanks for sharing :)
[holli]: gives me goosebumps every time I watch it
holli gotta grab some groceries before dawn. l8ters

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2017-12-15 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (433 votes). Check out past polls.

    Notices?