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

Pages: 1-4041-

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-08 2:17

Dumbing down the sigil system for no good reason.

Name: Anonymous 2012-01-08 2:45

>>1
Role is just another name for abstract class/trait/interface/mixin/typeclass

Name: Anonymous 2012-01-08 2:46

>>3
There are so much buzzwords in this world!

Name: Anonymous 2012-01-08 4:52

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.

Name: Anonymous 2012-01-08 5:42

>>5
because if(expr) speaks FrozenVoid.

Learn to if (expr)

Name: Anonymous 2012-01-08 6:01

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).

Name: Anonymous 2012-01-08 12:22

>>7
I'd rather have just one
Then pick just one. It's Perl, not Python.

Name: Anonymous 2012-01-08 13:26

>>5
Why do you want to write if(1)?

Name: Anonymous 2012-01-08 13:42

>>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.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-08 13:42

>>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: Anonymous 2012-01-08 13:43

>>10
s/force space of code/forced spacing of code/

Name: Anonymous 2012-01-08 13:44

(lambda (x)
       (lambda (y z)
         (* x y z)))


lrn2closure

Name: Anonymous 2012-01-08 13:44

>>11
There are better ways to tell if(expr) isn't a function call. Fuck all the languages that do this shit.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-08 13:46

>>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: Anonymous 2012-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: Anonymous 2012-01-08 14:09

>>16
How about you scrub my anus with your minuscule penis.

Name: Anonymous 2012-01-08 14:10

>>13
(uncurry 2 (curry 1 call (curry 3 *)))

Name: Anonymous 2012-01-08 14:18

>>17
That's hot.

Name: Anonymous 2012-01-08 14:25

>>10
Consider using a macro

Name: Anonymous 2012-01-08 14:36

>>13
what the fuck is this? why not use something like python's nonlocal statement instead?

Name: Anonymous 2012-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" }

Name: Anonymous 2012-01-08 16:24

say

What is this gay shit?

Name: Anonymous 2012-01-08 16:30

If I can do it in C, I want to be able to do it in a high level language. Fuck the forced spacing of code.

Name: Anonymous 2012-01-08 16:50

>>23
It's an identifier string for a function. Many languages have them.

Name: Anonymous 2012-01-08 17:40

>>14
Such as, mr King of Parsing?

Name: Anonymous 2012-01-08 19:35

>>5
I think doing what you're doing is retarded. Nonetheless, forcing people into coding in ONE WAY ONLY goes against Perl's principles of TIMTOWTDI

Name: Anonymous 2012-01-08 20:20

>>27
You can write Perl 6 in any way you like:
http://perlgeek.de/en/article/mutable-grammar-for-perl-6

Name: Anonymous 2012-01-08 22:14

>>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: Anonymous 2012-01-08 23:18

>>29
Are you likely to chain that many closures? No matter, I am:

@foo.grep: {...} ==> .map: {...} ==> .reduce: {...};

Nested what now?

Name: Anonymous 2012-01-08 23:35

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.

Name: Anonymous 2012-01-08 23:46

>>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?

Name: Anonymous 2012-01-08 23:59

if(expr) considered ugly as fuck, but I agree you should be able to use it.

Name: Anonymous 2012-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.

Name: Anonymous 2012-01-09 1:09

>>31
See >>28

>>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.

Name: Anonymous 2012-01-09 1:10

see >>28
That is fucking stupid. No.

Name: Anonymous 2012-01-09 1:16

>>36
Your loss.

Name: Anonymous 2012-01-09 1:36

I can't tell if I'm horrified or I love it.

Name: Anonymous 2012-01-09 1:45

I've yet to see someone name one good change.

Name: Anonymous 2012-01-09 2:50

>>39
There are some obvious improvements like formal parameters and everything is a reference.

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

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