Random Perl 6 syntax rant

Simon Wistow simon at thegestalt.org
Tue Apr 1 18:05:16 BST 2008

On Tue, Apr 01, 2008 at 09:11:09AM +0100, Andy Wardley said:
> Here's my anti-favourite new unintuitive Perl6 syntax snippet.
>   for =$*IN -> $guess {
>      ...
>   }

So the use of sigils raises interesting questions. 

Python happily (apparently) does without Sigils. So do a lot of other 
languages like C. Except when it doesn't although whether * and & are 
sigils is a matter of debate.

Charles Simonyi 'invented' a way of retconning textual sigils into BCPL


which provided a verbose but expressive way of having sigils. 

Microsoft later bastardised Hungarian Notation into the camelCaps 
abortion that is MFC. 

So clearly annotating a variable with a type is useful - the question is 
where along the spectrum you want to lie - full on verbosity or minimal 

I happen to like the level Perl5 has struck although, to be fair, I have 
no idea if that's just because it's what I'm used to. I understand the 
confusion between refs and normal variables 


but actually all those make perfect sense to me. I suppose the only way 
to simplify them would be to make all subroutines pass-by-reference and 
simplify down to 


but, and again maybe this is just inertia, that doesn't make sense to me 
- the $ in $array[0] tells me I'm getting a single value back. Again 
maybe this is a distinction that gets blurred when all you have is pass 
by reference since $array[0] could pass back and array itself but we'll 
leave that for now.

As an aisde I have real problems working with Python (and I've written 
some mildly large and complicated programs in it). This is not bash 
against Python but an anecdotal piece of evidence. I'm told that I have 
a very mild form of dyslexia (or similar) which manifests itself as a 
problem with pattern recognition. This normally isn't a problem but, 
when I'm tired, I can't read Python. Again, maybe it's a familiarity 
thing but I find that the lack of sigils and braces causes a problem 
trying to follow flow. As a corollary however I actually also have a 
problem reading strangely formatted English or text with no punctuation 
when I'm tired as well.

I felt the same revulsion as you when I read that Perl6/Rakudo. Again, 
possibly this is in part to the unfamilarity but I think it goes deeper 
than that. 

I'm sure that the Perl6 people will tell us that 99% of Perl6 will look 
like Perl5 and that this is just the corner cases, the golfing tools, 
the elements that will allow epxressive minimalism in the right place in 
the same way that we can do stuff like

    do_something foreach @item;


	exit unless $stay_alive;

in Perl5.

Yet every example we see looks alien and unfamiliar - the edge cases 
seem to be the norm. Maybe it's just the Perl6 team stretching their 
wings but aren't the two major complaints about Perl that there are too 
many sigils and too many ways to do things - what's the advantage of 
adding more sigils and more ways to do things. Maybe we're mistaken 
and we've got the wrong idea but when *everyone* apart from the inner 
cabal (not to imply that P6 development is exclusive, it's anything but) 
is confused, even the party faithful then maybe there's some 
communication problems going on.

So, why does 

    for =$*IN -> $guess

fill me with The Fear[tm]?

Well, for a start (and this is a personal thing), no comforting brackets 
and braces to help punctuate the syntax. Does the for apply to the =$*IN 
or to both the $*IN and the $guess? I can work it out but it's not 
immediately clear. 

And is that = a sigil or an operator? Again, I can work out that it's 
actually any operator but it's not immediately obvious. To =$* looks 
like an emoticon for someone in a top hat and sunglasses giving me a 
kiss. But that's just me.

Playing the familiarity card again but 

	for =$*IN -> $guess

isn't obvious what'ts going on without any context. If that was 
presented to me cold I'd guess it meant a short hand for 

	while ($*IN != $guess) {


	foreach my $guess ($*IN) {


is far more 'intuitive'. I'd actually like to see something more like TT

	foreach my $guess in ($*IN) {



	foreach in ($*IN) {


except that I can't quite get over the fact that $*IN to me looks like a 
single item

	foreach in ($*IN.lines) {



	foreach in (@*IN) {


would be better for me (the @ and $ magically switching the context of 
$*IN and the foreach forcing an implicit iterator for things that can 
support it) 

Anyway, this has been my attempt to at least rationalise why I don't 
like this syntax rather than just saying "Euuuch".



More information about the london.pm mailing list