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

Perl6 thread

Name: Anonymous 2011-01-09 22:35

There are too many ways to do it.

The completely backwards way:

> sub foo(&f) { f() }
{ "hi".say }.&foo();
hi


On the other hand, closures are much nicer now (JavaScript needs this):
> say (1,2,3,4,5).reduce: { $^a + $^b };
15

Note about .reduce: it only supports binary functions.

A note on operators:
Hyperops, eg: (1,2,3,4) «+» (5,6,7,8)
These are permitted to auto-parallelize (implementation dependent.)
Lazy meta-ops, eg: 1,2,3,4 Z+ 5,6,7,8
These support lazy evaluation. The result is generated as needed.
Reduction meta-ops, eg: [+] 1,2,3,4,5
Triangular reduction: [code][\+] 1,2,3,4,5 # result is (1,3,6,10,15)[code]
These are basically .reduce(*[b][i]op[/i][/b]*) with the binary operator provided.

Name: Anonymous 2011-01-09 23:23

Jesus, this is crazier than even I expected

Name: Anonymous 2011-01-10 1:40

>>1
i liek perl6 cuz it reminds me so much of haskal hahahahahahahaha lol ^___^ i rly liek haskal (and i'm from /g/ hahaha nice to meet u haha lol hahahahaha lol)

Name: Anonymous 2011-01-10 2:25

>>1-
Do you understand why I say that Perl 6 has an operator for everything!, now?

Name: Anonymous 2011-01-10 6:02

say "hi";

Name: Anonymous 2011-01-10 10:14

>>4
I wouldn't go so far as to say it has an operator for everything, but it does have three operators for nothing:

{ ... }
{ !!! }
{ ??? }
(nullary, of course)

http://perlcabal.org/syn/S03.html

Name: Anonymous 2011-01-10 11:04

>>4
NB. whatever-star is not classified as an operator. I think it's classified as a type in the auto-currying form.

Name: Anonymous 2011-01-10 11:15

>>6
I praised the power of Perl's Yada Yada Operator many times.
It is actually useful:
1. Your sub function { ... } example codes will be actual VALID Perl 6 CODE.
2. When you're working on a complex function, you can implement part of it later, using The operator on that branch:
if (something) {
    ...; //TODO: we've got something, what to do?
} else {
  // Let me work on this first
}

3. It's cute.

>>7
I think it can be classified as meta-operator, like «»/»«.

Name: Anonymous 2011-01-10 11:18

>>6
The lol contextualizer

Name: Anonymous 2011-01-10 11:21

>>6
infix:<andthen>
It's not the same of Haska l's >>?

Name: Anonymous 2011-01-10 17:14

I for one would like to see the Hammer operator become more prominent.

--;

Name: Anonymous 2011-01-10 21:37

>>11

What does it do?

Name: Anonymous 2011-01-11 1:18

>>12
it mobilizes ur dorfs to reduce the preceding object by one unit after evaluation

Name: Anonymous 2011-01-11 1:25

These support lazy evaluation. The result is generated as needed.
No CSE, no sharing, just call-by-name.  Certain people fucking hate that myth that you can add some sort of primitively deferred computation to a strict applicative-order language and add "lazy evaluation" to your feature list.

Name: Anonymous 2011-01-11 1:45

>>14
Certain people need to get their heads out of their dog's ass.

Name: Anonymous 2011-01-11 2:38

>>15
U MENA HASKAL!

Name: Anonymous 2011-01-11 8:51

>>1
BSD vs System-V

Name: Anonymous 2011-01-11 8:52

>>17 fuck wrong thread

Name: Anonymous 2011-01-11 9:07

>>15
They did, after the said dog died ;_;

Name: Anonymous 2011-01-11 11:21

>>14
Take it up with Larry Wall. No really--you can, he hangs out on IRC all the time. And I don't mean that in the "go away" sense, I mean it in the We're doing The Whirlpool-Larry Wall sense, i.e. if you can make a good point about it the spec and implementation will be revised.

Name: Anonymous 2011-01-11 15:11

[fuck-off] >>1-20

Name: Anonymous 2011-01-11 15:50

if you can make a good point about it the spec and implementation will be revised.
I state that you are not a Perl programmer because you retain too much sanity, thus you are not eligible to participate in this discussion.

Name: Anonymous 2011-01-11 16:33

>>22
He obviously means »If you can show a cool one-liner that prints out `Just another Perl hacker,´«

Name: Anonymous 2011-01-11 23:41

>>22
Encouraging someone go visit IRC to be shot down by The Larry isn't exactly diagnostic of sanity (though it doesn't necessarily make one insane.)

One: there is a measure of call-by-need in Perl 6's lazy evaluation. Two: it is often an implementation detail according to the spec. Three: >>14 argues from some false sense of purity. Four: >>14 would throw out utility in order to promote that sense of utility. Five: Mr. Wall is very entertaining when he bursts peoples' respective bubbles.

Name: Anonymous 2011-01-11 23:56

>>24
It's called trolling, dipshit.

Name: Anonymous 2011-01-12 0:09

>>25
Don't take it so personal!!

Name: Anonymous 2011-01-12 5:39

Larry Wall is an awesome guy, and anybody who tells you otherwise is  DAMN EVIL LIAR and is probably jealous.  Ignore the rantings and ravings of JEALOUS, JEALOUS FAILURES.  The Ruby faggots, Guido, John McCarthy, Knuth, and the Jews have all been trying to take Larry Wall down for years but they can't because he's just too damn good.

Name: Anonymous 2011-01-12 6:02

>>24
It's misleading.  One would expect lazy evaluation to be, well, lazy evaluation, and not merely a nullary "thunk" that gets executed when "its value is needed".

Name: Anonymous 2011-01-12 8:17

Does perl 6 have nondestructive s///?

Name: Anonymous 2011-01-12 12:31

>>28
You might want to read up on it, because it sounds like you've got the wrong idea.

Name: Anonymous 2011-01-12 21:51

>>30
I don't know if a non-destructive version has been implemented yet, but I know f/e this works:

  my $a = "abcdef";
  my $b = $a.map: { ~~ s/a/z/; $_ }

  say $a; # abcdef
  say $b; # zbcdef

is copy is a great thing along similar lines:

sub foo($bar) { $bar = 'x' }; # error, read-only reference
sub foo($bar is rw) { $bar = 'x' }; # ok, rw reference
sub foo($bar is copy) { $bar = 'x' }; # ok, local copy

Name: Anonymous 2011-01-18 12:19

Recently seen on IRC (slightly modified):

subset Even of Int where * %% 2;
subset DivisibleByFour of Int where * %% 4;
say DivisibleByFour ~~ Even
    -> Bool::True


The type system is nicer than I thought.

Name: Anonymous 2011-01-18 12:49

>>29
Is it necessary?

Name: Anonymous 2011-01-18 12:52

>>32
    proto sub fib (Int $) {*}
    multi sub fib (Int $n where 0|1) { return $n }
    multi sub fib (Int $n) { return fib($n-1) + fib($n-2) }

Name: Anonymous 2011-01-18 13:06

>>33
Perl 5 got it, apparently after much moaning.

>>34
I was hoping you'd pick up on the Halting-complete type system.

The above code is matching against the parent type. It's a bug or something, but %% 3 would have matched Even as well. I think the correct behaviour is that type comparisons should always result in False unless they are exactly equal or LHS is defined as a subset of RHS.

Name: Anonymous 2011-01-18 13:58

>>31
I still don't get the use of : ... for example on reduce or in assignments....

Anyone care to explain???

Name: Anonymous 2011-01-18 14:07

>>32
Oh god.

Name: Anonymous 2011-01-18 14:07

>>36
It's a placeholder.

Name: Anonymous 2011-01-18 14:12

>>36
It's the Yada Yada Operator. Means "not implemented, I'll do it later".

Name: Anonymous 2011-01-18 14:17

>>35
I was hoping you'd pick up on the Halting-complete type system.
I remember that in some version of Perl, simply parsing Perl code was not guaranteed to terminate.

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