Search this site:

Perl6 and sigils

Zack, Wouter: Yup, Perl 6’s scheme changes to reduce confusion to the programmer and to make the language better Huffman coded. Why? As for the programmer, it comes out of observation - Changing the sigil depending on what you are expecting to get back (i.e. a hash has a ‘%’ sigil, but if you only want one value off it, you use the ‘$’ sigil, as it indicates a scalar variable) confuses more often than it helps - Specially newcomers. Besides, it will be easier for the interpreter itself - The sigil will become an invariant but required part of the variable name itself. Hence, Martin will be happier, as there will no longer be different namespaces under which to store your variables. Oh, BTW, Martin: Not only Perl behaves this way. Ruby also uses that concept - There, you have local variables (no sigil), instance variables (‘@’), class variables (ugly ‘@@’) and global variables (‘$’). I remember in old (Quick|GW)BASIC you had numeric variables (no sigil) and string variables (postfix sigil ‘$’) as well. Any others? Now, about the Huffman coding part, WTF? It is one of the design goals of Perl 6 to make the most often used operators be the shortest, so you, programmer, don’t wear out your keyboard and lose your valuable fractions of seconds typing i.e. ‘->’ for a method call when you can just type a ‘.’ - Similarly, currently you have to type too many characters for the (too common) dereferencing - If you have a reference to a hash of arrays of arrays of objects on which you want to call methods, you have to do $something->{key}[0][0]->boo - Whereas with Perl 6 you will only have to do $something{key}[0][0].boo Anyway, I cannot elaborate much further, as I’ve been -at best- just a bystander. But yes, large changes loom in Perl’s future. Let see what comes on… And when. Sigh.


gwolf 2008-03-26 19:44:26

Perl5 isn’t vanishing at all!

Of course, the Perl people are not implying, by a long shot, that Perl6 will replace Perl5. Not ever, BTW. Not only what you say is true (although you should take a look i.e. to Lingua::Romana::Perligata (and, for your life, don’t miss out Damian Conway’s paper describing/designing Lingua::Romana::Perligata, a true piece of genius) - There is linguistic logic behind this decision (this means, it should be more natural to write/learn Perl6 than Perl5). That aside… I do not have too much faith in Perl6 anyway. It has become too complex, too esoteric… And too vaporware :-(

Russ Allbery 2008-03-25 10:43:36

Why Perl 5 will live on

I think it’s things like this that are why Perl 5 isn’t going anywhere, and why I’ll be surprised if Perl 6 ever catches on. If I want to learn a new language, there are several out there that look like they might be more productive than Perl once I get to know them extremely well. I can understand the point about beginners, but I’m not a beginner, and having $foo, %foo, and @foo hold the same data in different formats is a common Perl idiom and one that I find very useful.

I have a hard time imagining why I’d want to bother with Perl 6 when Perl 5 works fine and supports expert features with which I’m already comfortable. It might be friendlier to beginners, but that isn’t a feature for me.

I suppose it would be an improvement if it helped other people maintain my code, but I’ve never seen any real problems with this in particular. Perl isn’t an easy language for beginners, but I don’t think the changes in Perl 6 are anywhere near enough to change that.

Ah well. It’s all speculation at this point, and I could end up being very surprised.

Steve Haslam 2008-03-25 06:19:00

basic sigils

BBC Basic also had a postfix “%” for integer variables (bare names meant floating-point, and “$” meant string). “@%” was a legal variable name, although it was a special one used to control formatting. “#” was a suffix to some keywords to indicate the next variable was a filehandle to, so it kind of looked like “#” was a prefix sigil for a file variable if you squinted (PRINT#file%, “foo”:BPUT#file%, 13)

This in combination with the odd “?” “!” and “$” operators instead of having the more-traditional “PEEK” and “POKE” keywords was probably a good grounding for me dealing with programs that looked like line noise :)