You learn
something new every day :)
http://dev.perl.org/perl6/doc/design/syn/S02.html
Unlike in Perl 5, you may no longer put whitespace between a sigil and its following name or construct.
perl -wle" my $ x = 6; die $x "
6 at -e line 1.
Haven't noticed this in the perldocs (probably a good thing).
Re: white spaces between the sigil and the variable ( $ x = )
by JavaFan (Canon) on Oct 15, 2008 at 00:12 UTC
|
Note that you can put a newline after the sigil most of the time as well, except for many of the punctuation variables - the parser accepts spaces after the sigil, but not newlines.
I've known for this quite some time, and I tried to make a JAPH with no line being more than one character wide 1. I haven't succeeded. A quicky attempt I just made (my original tries have been lost in time), run with 'perl -M5.010':
$
_
=
q
q
J
u
s
t
a
n
o
t
h
e
r
P
e
r
l
H
a
c
k
e
r
q
;
s
s
s
seg&say
(None of the lines above match /^$/)
1
To avoid having to write I have this amazing JAPH, but the margin isn't wide enough for it... | [reply] [d/l] [select] |
Re: white spaces between the sigil and the variable ( $ x = )
by eyepopslikeamosquito (Archbishop) on Oct 15, 2008 at 07:07 UTC
|
I stumbled upon this while composing Saturn when, to accurately fit the Saturn shape, I needed to split $I across two lines here:
$_=_^q-q-),&$I(20,41-!q- ;;; -,$_=F|K),$
I->(15,31,$_=&$R(4-!q- ;;; -)),&$I(13-!"
| [reply] [d/l] [select] |
Re: white spaces between the sigil and the variable ( $ x = )
by blazar (Canon) on Oct 16, 2008 at 05:38 UTC
|
I personally believe (but I am not 100% sure) it was Abigail (who is "our" Abigail as well) in clpmisc who originally "told" me about this feature: if not him, then certainly someone else there.
| [reply] [d/l] |
|
(who is "our" Abigail as well)
Alas, not any more, since some years now. - But it must be him; his main objection to Perl 6 is significant whitespace, and I'm with him on that one. I detest python for it's significant whitespace (or abuse of indentation) - python scripts look like full of dangling code to me - and I love the whitespace liberty of perl 5 which lets me align code vertically, like in
$foo {three} = $doit -> (1 );
$quux {two} = get_that (25);
which improves readability, imho. | [reply] [d/l] |
|
In Perl6, you don't have to give your aligning up...
$foo. <<three>> = $doit. (1);
$quux. <<two> = get_that(25);
... or something :-)
[]s, HTH, Massa (κς,πμ,πλ)
| [reply] [d/l] |
|
$foo{ three } = $doit->( 1 );
$quux{ two } = get_that( 25 );
There. All better now :) (And (probably?) compatible with Perl 6)
My justifictions:
- $foo {three} looks like the scalar $foo juxtaposed against a bare-block containing a bareword.
Conversely, this $foo{ says, hash; and this $foo{ three } is clearly addressing the element keyed with three in the hash named %foo.
- Ditto $quux {two}
- $doit -> (1 ); looks like the scalar $foo fired an arrow at a big-bottomed girl's left butt-cheek.
Conversely, this $doit->( 1 ) obviously dereferences the scalar $doit and attempts to call it as a subroutine passing 1 as the parameter.
- get_that (25) reads like an extract from a foriegn correspondant's newspaper article: "The bride, get_that (25), was resplendent in her gown of layered white taffeta..."
Whereas this get_that( 25 ); is obviously calling a subroutine.
Though if you're using a small enough font, that silly underscore seems to disappear, and suddenly it turns into Patrick McGoohan giving an order to that bit-part cast member you knew was destined to die this episode, because of his identifier.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
|
|
|
|
(who is "our" Abigail as well)
Alas, not any more, since some years now. - But it must be him; his main objection to Perl 6 is significant whitespace, and I'm with him on that one.
I personally believe that it was clear enough I was using "our" (in quotes, in fact) in the Pooh sense: indeed it used to be him, then he had an idiosyncrasy with the environment here, and voting and the like; he's definitely a clpmisc-kinda-guy. As you can clearly understand, he's rather radical in his choices and judgements - this whitespace thingie included. In fact Perl 6 is admittedly more whitespace sensitive than Perl 5, but... not that much! To even remotely mention Python (which has indentation as part of the syntax!) in these respects sounds mostly like a heresy to me!
Anyway tastes are tastes and Abigail is to say the least an extremely resourceful and skilled Perl hacker far above the top of my head, but as a general rule he found Perl 6's design to be too clean and neat, while he cherishes the "medieval-castle-like characteristics" of Perl 5. A matter we may discuss for hours without getting anything out of it if we have contrasting opinions...
| [reply] [d/l] |
|
|