Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Perl 6 vs Perl 5

Name: Anonymous 2012-01-08 0:35

Can we have a serious Perl 6 vs Perl 5 thread?

I've been trying to wrap my head around what roles are trying to emulate. Just an odd sort of OO way of programming?'

What else where significant changes?

Name: Anonymous 2012-01-09 6:54

I like hyperoperators. And i think you people are bitching too much about the space-before-parens thing.

Name: Anonymous 2012-01-09 11:07

>>41
YHBT

Name: Anonymous 2012-01-09 11:09

I don't get why Perl 6 changed the C-like (and Perl-like) syntax for no apparent reason, like the ternary operator (?? !! instead of ? :) and the change from for to loop. What was the point of that?

Name: Anonymous 2012-01-09 11:13

>>43
You can look up the rational for every design decision on your own, everything is very well documented.

Name: Anonymous 2012-01-09 11:15

>>43
'?' coerces to boolean.
'!' negates the return value of an operator, IIRC.

Name: Anonymous 2012-01-09 11:17

also, ':' is now used for specifying parameters

Name: Anonymous 2012-01-09 12:50

>>43 In fact, you can't overload an operator that starts with '!', because ! is reserved for negating any operator.

multi sub prefix:<iseven>(Int $n) { return ?($n % 2 == 0) }; say iseven 4; say !iseven 4;

OUTPUT:
Bool::True
Bool::False

This prints the same result (note that perl6 is full unicode compliant, at least as compliant as IBM's libicu is):
multi sub prefix:<¬>(Int $n) { return ?($n % 2 == 0) }; say (¬ 4); say (!¬ 4);

Name: Anonymous 2012-01-09 14:28

>>47
What does "i seven" mean?

Name: Anonymous 2012-01-09 15:02

>>48
"is even"


multi sub prefix:<is-even>(Int $n) { return ?($n % 2 == 0) }; say is-even 4; say !is-even 4;


There you go.

Name: Anonymous 2012-01-09 16:13

>>47
?($n % 2 == 0)
You should be writing $n %% 2, the ? is redundant since it's test:
> (1 == 2).WHAT
Bool()

And %% is shorthand for the same test you're writing.

Name: Anonymous 2012-01-10 12:28

Grammars seems cool.


grammar Str::SprintfFormat {
 regex format_token { \%: <index>? <precision>? <modifier>? <directive> }
 token index { \d+ \$ }
 token precision { <flags>? <vector>? <precision_count> }
 token flags { <[\ +0\#\-]>+ }
 token precision_count { [ <[1-9]>\d* | \* ]? [ \. [ \d* | \* ] ]? }
 token vector { \*? v }
 token modifier { ll | <[lhmVqL]> }
 token directive { <[\%csduoxefgXEGbpniDUOF]> }
}


code stolen from Wikipedia

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List