Beginning with ‘P’
2007-07-12 21:15:21
code
Yesterday I finally worked out what the deal with Perl 6 is. Basically it works like this. Perl 6 is the language. Anything that fits the standard can be a perl 6 interpreter. Perl 6 runs in a virtual machine, which is called parrot. The only - as far as I can tell - available perl 6 interpreter at the moments is pugs.
Confusion aside, I've started looking at perl 6 stuff, there's some really cool new syntax, like chained comparisons. In most programming langauges (like perl 5), you check if a number is in a range - let's say 101 to 305 inclusive - like this:
Edit: There's this bloody cat that keeps walking into the kitchen, so I've got to keep the door closed now. Which is irritating.
Confusion aside, I've started looking at perl 6 stuff, there's some really cool new syntax, like chained comparisons. In most programming langauges (like perl 5), you check if a number is in a range - let's say 101 to 305 inclusive - like this:
if ($x >= 101 && $x <= 305) { EXPR }
But in perl 6 you can now say:
if (101 <= $x <= 305) { EXPR }
Just like real maths. I'm sure there are other languages that do this - but I've never used any. You can also chain together multiple variables and numbers - which I'm sure could produce something nice and readable like this:
if (101 <= $x < $y <= 305) { EXPR }
But the first thing I tried to do was make it more unreadable, much more fun.
if (1 < $a > $b <= 7 < $c > $a) { EXPR }
Of course this breaks the syntax file for vim I have, so I suppose I'll have to look into that.Edit: There's this bloody cat that keeps walking into the kitchen, so I've got to keep the door closed now. Which is irritating.