No change in particular really pisses me off, but there are tons of stupid shit changed. Like now you're not supposed to use parenthesis for if/while/for. You have the option, but you have to add a space between the if and parenthesis otherwise it's a sub call. Really? if(1) { print "fuck perl 6\n"; } #INVALID PERL 6 CODE
Eval has been changed to try to become closer to sepples or some shit. In general it likes more like pseudo code. Why is say encouraged instead of print now? There's tons of other stupid shit but I can't be bothered to list them.
The whatever star should work like scala's underbar.
Perl6 adds three new ways of creating a closure (that i know of)
sub($lorem, %ipsum) { $lorem + %ipsum<dolor> } # same as p5
-> $lorem, %ipsum { $lorem + %ipsum<dolor> }
{ $^lorem + %^ipsum<dolor> }
* + *<dolor> # limited to operators
I'd rather have just one that looks like ruby blocks or lambdas in c# (i.e. that don't make me wanna scratch my eyes out).
>>6,9
I want to write if(expr) because that has been my style of coding. I fucking hate languages that restrict how you can write this shit. It might as well be Python with it's force space of code.
>>5 You have the option, but you have to add a space between the if and parenthesis otherwise it's a sub call. Really?
I can't tell if you're trolling or just plain stupid. Either way, a lot of programming languages follow this convention. The reason for this is because it's easy to tell what is and isn't a function call.
Name:
Anonymous2012-01-08 13:43
>>10
s/force space of code/forced spacing of code/
>>5
Before I forget, you might want to get a hold of the book "The C Programming Language" by K & R and then look at the coding style in that book. The authors usually put a space between the if and the () in order to differentiate between function and non function calls.
It just looks like Perl 6 just took a coding convention and made this into a rule.
Name:
Anonymous2012-01-08 14:07
>>15
I've read K&R you big fat doodoo head. I don't have to use everything about their coding style. I sill don't like languages that force this type of syntax bullshit.
Name:
Anonymous2012-01-08 14:09
>>16
How about you scrub my anus with your minuscule penis.
>>13
what the fuck is this? why not use something like python's nonlocal statement instead?
Name:
Anonymous2012-01-08 16:07
>>5 You have the option,
It looks like you do, but you don't. You can always parenthesize an expression, but the expression will be AST'd by the time if sees it. Just like you can't write iftrue and expect it to work, you can't write if(expr) and expect it to match the conditional.
>>15
That's almost exactly the reason for it, but it's not about the user, it's about the grammar. You can be cheeky:
sub if( $t, $fn ) { if $t { $fn($t); } }
1.&if: { say "$_: yup" }
>>8
Eh finish the sentence? Rather one that looks good than 3 ugly ones.
All of p6's options require you to nest brackets when chaining method calls except for the whatever which is limited to operators. method1({ $^x ... }).method2(sub($x){ ... }).method3(-> $x { ... }).method4
while with c# or ruby method1( x => ... ).method2{ |x| ... }.method3 [code]
Name:
Anonymous2012-01-08 23:18
>>29
Are you likely to chain that many closures? No matter, I am:
There are more ways of being able to tell that if(expr) is not a function call. The fact that the Perl devs have reduced this to whether or not there is a space in between if/for/while and the parenthesis is nonsense. It's absolutely unacceptable.
Think about it from a person reading code's perspective. You see an expression in parenthesis, and the word "if" before it. Do you think to yourself "Is that 'if' a function call? I forget the purpose of 'if'. Is it a keyword?" Again, complete nonsense. I expect higher level languages to give me AT LEAST the freedom C gives me. Anything less and it's not worth using.
>>30
I just wanted to show them all in one line. (though in c# (linq) and ruby you do see that quite often)
With the feed operator it looks even worse and it doesn't work with my version of rakudo.
Why not just have something like $x -> ...?
What's the idea behind this ugly pointy-block thing?
if(expr) considered ugly as fuck, but I agree you should be able to use it.
Name:
Anonymous2012-01-09 0:23
Perl is a total opposite of Lisp.
- While Lisp was discovered, Perl was forged.
- While Lisp is small and beautiful, Perl is bloated and ugly.
- While Lisp says there is The Right Thing, Perl proposes myriad of wrong ways.
>>32
The feed operator arguably looks better in many situations. It looks natural to put subsequent feeds on new lines without further indentation: @foo.grep: /.../
==> .map: { ... }
==> .reduce: { ... };
Or you could indent once if you really want to.
It doesn't work in your version of Rakudo because it's still under a rewrite. I am pretty sure it worked in the last Star versionthough. It's in the spec and hopefully in the next Rakudo Star.
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?
>>43
You can look up the rational for every design decision on your own, everything is very well documented.
Name:
Anonymous2012-01-09 11:15
>>43
'?' coerces to boolean.
'!' negates the return value of an operator, IIRC.
Name:
Anonymous2012-01-09 11:17
also, ':' is now used for specifying parameters
Name:
Anonymous2012-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);
multi sub prefix:<is-even>(Int $n) { return ?($n % 2 == 0) }; say is-even 4; say !is-even 4;
There you go.
Name:
Anonymous2012-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.