🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
Nemokosch gist.github.com/2colours/795bc0608...ef1ac43bf5 09:59
what happened here?
works when `andthen` starts on the same line 10:00
reminds me of ASI in Javascript... 10:01
CIAvash Nemokosch: docs.raku.org/language/syntax#Impl...in_blocks) 10:10
tellable6 CIAvash, I'll pass your message to Nemokosch
Nemokosch oh crap, this is really ASI 😬 10:14
Voldenet ASI is not that bad, enforces specific formatting discipline 10:15
Nemokosch wouldn't use the word "discipline" here 10:21
it's rather just a certain style, a not necessarily good one
Voldenet Sure, good and bad are relative to moral standpoint after all ( ゚‿ ゚) 10:23
Nemokosch I mean, discipline implies a certain carefulness, as if it were superior and not just a certain choice you are stuck with for technical reasons 10:25
and for colon method calls, this feels like the final nail in the coffin
Voldenet Just my opinion, but I find colon method calls messy 10:28
Nemokosch this `andthen` was already a bit hackish attempt to make use of them but hell, not at the cost of adding much more line noise than just using parens
CIAvash You have some options, but you may not like them 10:29
<1 3 5>.map: {
$_**$_
} andthen .say;
<1 3 5>
==> map({$_**$_})
==> say();
Nemokosch I never managed to understand this long arrow to be honest 10:30
Voldenet long arrow is actually quite cool syntax
CIAvash "feed operator"
Nemokosch Sometimes it did seem clean and concise but I just didn't grasp how it works 10:32
Voldenet m: sub accept-long-arrow(&code, $x) { $x.&code }; ^10 ==> accept-long-arrow { .map(* * 2) } ==> say() 10:33
camelia (0 2 4 6 8 10 12 14 16 18)
Voldenet sequencer operators precedence is low, which is pretty nice 10:35
Nemokosch what is this $x &code black magic xD 10:38
CIAvash docs.raku.org/language/operators#i...dop_.& 10:39
Nemokosch this one I know 10:40
lizmat m: sub double($text) { say $text x 2 }; "foobar".&double 10:48
camelia foobarfoobar
Voldenet in fact, feed operator lets you skip a lot of () and {} 10:51
m: sub accept-long-arrow(&code, $x) { code($x) }; ^10 ==> accept-long-arrow *.map: * * 2 ==> accept-long-arrow *.say
camelia (0 2 4 6 8 10 12 14 16 18)
Nemokosch why does this work? 10:52
Voldenet basically, WhateverCode can be invoked 10:53
m: (* * 2)(2).say
camelia 4
Voldenet non-fancy way of writing this would be: 10:55
m: sub accept-long-arrow(&code, $x) { code($x) }; ^10 ==> accept-long-arrow({.map({ $_ * 2 }) }) ==> accept-long-arrow({.say})
camelia (0 2 4 6 8 10 12 14 16 18)
Voldenet and feed operator just passes everything on the left as last parameter of the given function 10:58
Nemokosch > and feed operator just passes everything on the left as last parameter of the given function 11:07
hmmm 😮
Voldenet (ofc, the code above is pointlessly verbose, you could write this in a lot shorter way)
m: ^10 ==> map * * 2 ==> say() 11:08
camelia (0 2 4 6 8 10 12 14 16 18)
[Coke] tmux a 13:12
Voldenet sessions should be nested with care, unset $TMUX to force
[Coke] thtop
Nemokosch > ^10 ==> map * * 2 ==> say() 15:46
exactly the kind of stuff that makes me so confused
is this arrow really just a way to invert the call chain? 16:34
what I mean is that it doesn't seem to do anything special with a list, it doesn't iterate over it or anything
Voldenet nope 16:37
Voldenet …well it also has this funky behavior 16:42
Nemokosch 👀 16:43
Voldenet m: my $foo = class { method append(|x) { say x }; }.new; ^10 ==> $foo ==> say()
camelia \((0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
(0 1 2 3 4 5 6 7 8 9)
Voldenet Why? Absolutely no idea
[Coke] Which part of that exactly is funky? 16:50
Nemokosch is there a straightforward way to call methods rather than bare functions? 16:51
[Coke] m: ^10 ==> map({ .say }) 16:52
camelia 0
1
2
3
4
5
6
7
8
9
[Coke] docs.raku.org/routine/==%3E 16:53
Nemokosch map is a bare function in this example, no? 17:01
Voldenet [Coke]: the part where .append can be called, it's… weird 17:18
m: ^10 ==> 42
camelia ===SORRY!=== Error while compiling <tmp>
Only routine calls or variables that can '.push' may appear on either side of feed operators.
at <tmp>:1
------> ^10 ==> ⏏542
Voldenet m: ^10 ==> class { method push(|x) { say x }; }.new
camelia ===SORRY!=== Error while compiling <tmp>
Only routine calls or variables that can '.push' may appear on either side of feed operators.
at <tmp>:1
------> ==> class { method push(|x) { say x }; }⏏.new
[Coke]_ I assume the append is called because that's how you add a bunch of data to the end of an array, and you've given it something that isn't callable in the pipeline 17:24
m: my @a; ^10 ==> @a; say @a.elems
camelia 10
[Coke]_ and the "42" earlier doesn't let you invoke it *or* save data in it.
[Coke] nemokosch, yes map is a bare function. no you can't call methods in a chain directly. if you want to use methods.. use them directly. 17:25
Voldenet m: ^10 ==> class { method append(|x) { say x }; }.new 17:26
camelia ===SORRY!=== Error while compiling <tmp>
Only routine calls or variables that can '.push' may appear on either side of feed operators.
at <tmp>:1
------> > class { method append(|x) { say x }; }⏏.new
Voldenet my $foo = class { method push(|x) { say x }; }.new; my @a; ^10 ==> $foo
m: my $foo = class { method push(|x) { say x }; }.new; my @a; ^10 ==> $foo
camelia Cannot resolve caller append(<anon|1>:D: List:D); none of these signatures matches:
(Any:U \SELF: |values)
in block <unit> at <tmp> line 1
Voldenet m: my $foo = class { method append(|x) { say x }; }.new; my @a; ^10 ==> $foo
camelia \((0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
[Coke] the SORRY is at compile time there. 17:28
you're trying to pass something that has to be figured out at runtime, I think.
Voldenet Yes, but .push is not actually needed or used 17:29
[Coke] Assuming that's a change that was made in the implementation and not in the error message. 17:31
(append lets you append a bunch, push is one at a time) 17:32
Looks like it's hardcoded to *use* append, so even if you define a push, it doesn't fall back to it. 17:33
seems bug worthy.
Nemokosch [\,] $seq andthen .toggle: !*.repeated andthen .last 17:34
looks good enough I think
by the way
I've shown this ASI-looking example gist.github.com/2colours/795bc0608...ef1ac43bf5
Voldenet it's a minor bug either way, it was meant to be used with arrays I suppose
Nemokosch it is indeed mentioned ("implied separator rule") 17:36
but what is the rationale behind?
`*.grep: {}` is a method call syntactically, it doesn't contain the block on the top level
CIAvash FWIW design docs say this: "If the operand on the sharp end of a feed is not a call to a variadic operation, it must be something else that can be interpreted as a list receiver, or a scalar expression that can be evaluated to produce an object that does the KitchenSink role, such as an IO object. Such an object provides .clear and .push methods that will be called as appropriate to send data. (Note that an IO object used as a sink will force eager 18:35
evaluation on its pipeline, so the next statement is guaranteed not to run till the file is closed. In contrast, an Array object used as a sink turns into a lazy array.)" design.raku.org/S06.html#Feed_operators
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/05/09/2022-19-docublast/ 18:42
Nemokosch oh nice 19:00
so <( and )> basically manipulate $0? Am I following? 19:01
lizmat no, they limit the match 19:02
lizmat in that example, there is no $0 19:02
m: say "foobarbaz" ~~ / foo <( \w+ )> baz /; say $0
camelia 「bar」
Nil
Nemokosch hmmm 19:03
I guess I'm mixing it up with Python regexes... what _would_ $0 denote actually?
lizmat m: say "foobarbaz" ~~ / foo ( \w+ ) baz /; say $0 19:04
camelia 「foobarbaz」
0 => 「bar」
「bar」
lizmat using positional captures creates more information, that you may not need
Nemokosch in my mind, it was the whole matching string 19:05
lizmat m: "foobarbaz" ~~ / foo ( \w+ ) baz /; say $/; say $0
camelia 「foobarbaz」
0 => 「bar」
「bar」
lizmat also, you don't need to use both, you can use either
m: say "foobarbaz" ~~ / foo <( \w+ baz /
camelia 「barbaz」
lizmat m: say "foobarbaz" ~~ / foo \w+ )> baz / 19:06
camelia 「foobar」
lizmat it's like \K in Perl, but on steroids and both ways ?
Nemokosch I still tend to forget the regex; the interface is highly different compared to the Python module 19:09
seems like even $0, $1, $2 stuff is some kind of match object, not a raw string
lizmat indeed... $0 is just short for $/[0] 19:14
and $<foo> is just short for $/<foo>
a match creates a Match object, that may consist of more sub-Match objects 19:15
Nemokosch okay, I will eventually remember, thanks 😄 19:19
On a different note: overall it's pretty sad how the whole Perl community is divided deep down 19:20
lizmat I don't know, I don't consider myself part of the Perl community anymore 19:23
so I'm not keeping up-to-date on developments there
Nemokosch I mean yes, probably the biggest split is between current Perl and well, what was thought to become current Perl... 19:28
lizmat I tried for the longest time to make that happen... alas, I gave up 19:31
Nemokosch Anyway, I just don't get the mourning attitude I come across on forums... indeed, it's not 2000 anymore but there isn't much point in wondering how we could pretend it were
lizmat in hindsight, I think I didn't give up early enough
Nemokosch oof 19:32
lizmat I hadn't realized that the active/vocal members of the Perl community had already driven away most of the more liberal people 19:33
so those who remained behind were hard-core anti what is now Raku
and those who remained behind, would blame all of the issues on what is now Raku 19:34
and now many of the issues that started the whole (what is now) Raku effort, still remain in Perl
and cannot be fixed without breaking compatibility 19:35
and that's basically the only thing that Perl has going for it in this day and age
El_Che lizmat: www.youtube.com/watch?v=L0MK7qz13bU
Nemokosch 🤣 19:36
lizmat yeah, got the hint.... I'll be afk and cool down &
El_Che lizmat: you because we care :)
just
Nemokosch I was barely alive in the late 90's early 2000's so it's not like I could give some proper analysis 19:37
lizmat before I go, some things to ponder from those days
Nemokosch but I think what happened was mostly a shift in emphasis 19:38
perhaps people accepted that shell would suck, no matter what xD
lizmat in the early 2000's I was working on a search engine, and as a sample, I was indexing the p5p archive
and I was wondering why some days took so much longer than other days to index
turns out, those days had 600+ messages on the mailing list / day
that's almost one message every 2 minutes, continuously 19:39
and they were a lot of not so friendly happy messages :-( 19:40
afk&
Nemokosch I don't know and maybe I don't even wanna know. I think I've expressed my own principle already. I just happen to think that 1. Perl is really good for certain things and 2. leaving people space and freedom to develop their own style and own cleverness is inspiring 19:54
I don't regret starting Raku and I think the world would be a bit emptier place without it 19:55
but in the end, it's "just" a programming language, not a manifesto or something 19:56
at > but in the end, it's "just" a programming language, not a manifesto or something 20:13
raku feels more like a manifesto in the intentional way the community is built & the thought put into it
Ofun and all that
ecocode___ hi, I'm pretty old and my eyes prefer reading stuff on e-ink device instead of web-browser. By any chance, is the raku guide and/or the raku documentation available in epub format ? 20:37
at Pod can render Markdown that you can throw at pandoc to get epub, you should be able to do that with the docs docs.raku.org/language/pod#Markdown 20:40
[Coke] the epub version has been broken for some time.
ecocode___ how come ? 20:41
[Coke] well, single file version. not strictly speaking an epub format.
ecocode___: bitrot. there's an open ticket, needs to be addressed.
ecocode___ ok thx 20:42
[Coke] github.com/Raku/doc/issues/3041 github.com/Raku/doc/issues/1981 (I'm sure there are others) 20:44
Please follow those tickets; hopefully once the build is unblocked, we can start addressing these issues again. 20:46
ecocode___ raw.githubusercontent.com/hankache...intro.adoc ... what format is that ? 20:56
euandreh ecocode___: looking at the extension, asciidoc 20:58
El_Che ecocode___: lo! Long time no see 20:59
Nemokosch mhm, this is exactly why I got into debate 21:04
ecocode___ El_Che: hello ! 21:06
I figured to get the raku guide in epub :) (```asciidoctor``` and ```pandoc```) 21:11
ecocode___ Not really readable though... 21:46
Guess I will have to read the web
at ecocode___: pandoc can read Asciidoc directly, maybe skipping `asciidoctor` could help layout-wise? 21:50
ecocode___ Hah? It did not like it on my system 21:57
at ecocode___: pandoc.org/demos.html example 28, looks like it needs some special syntax 21:58
ecocode___ Therefore I used asciidoctor to convert to docbook to feed pandoc
I'll check again tomorrow 22:00
at pandoc -s perl6intro.adoc -t asciidoc -o out.epub, no?
ecocode___ Such a potty Merello book (raku recipes) isn't sold in Epub, but pdf only 22:01
*pitty
I'd love to read that one
El_Che that sounds like an insult
potty Merello
msg him and ask 22:02
ecocode___ Ouch
Maybe I'll just buy the printed book
El_Che: you use raku in production? 22:03