🦋 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.
raiph r: say do for ^10 { .say; last 99 if $_ > 3 } 14:07
camelia ===SORRY!=== Error while compiling <tmp>
Calling last(Int) will never work with any of these multi signatures:
( --> Nil)
(Label:D $x --> Nil)
at <tmp>:1
------> say do for ^10 { .say; ⏏last 99 if $_ > 3 }
Can't open perl script "/home/camelia/rakudo-j-inst/bin/eval-client.pl": No such file or directory
lizmat m: use v6.c; say do for ^10 { .say; last 99 if $_ > 3 } 14:21
camelia ===SORRY!=== Error while compiling <tmp>
Calling last(Int) will never work with any of these multi signatures:
( --> Nil)
(Label:D $x --> Nil)
at <tmp>:1
------> use v6.c; say do for ^10 { .say; ⏏last 99 if $_ > 3 }
lizmat m: use v6.*; say do for ^10 { .say; last 99 if $_ > 3 }
camelia 0
1
2
3
4
(99)
ph88 hey guys, is it possible to change inputs to a function like it was a pointer ? 16:48
so after function call is done the input argument value was changed 16:50
lizmat m: sub foo($a is raw) { $a = 42 }; my $b = 666; foo $b; say $b 16:51
camelia 42
lizmat ph88 something like that ^^ ?
ph88 lizmat, yes that looks very good ! .. so the trick is in "is raw" ? 16:56
lizmat yes, if you're sure it is a single item that you're interested in
m: sub foo(\a) { a = 42 }; my $b = 666; foo $b; say $b # slightly different semantics 16:57
camelia 42
ph88 lizmat, do you know if it's possible to return multiple arguments ? 16:58
lizmat Raku only ever returns a *single* value
ph88 ok
lizmat *BUT* that value can be a List or an Array :-) 16:58
ph88 sure 16:59
is there a good library for reading raku source code into syntax tree ?
lizmat m: sub foo() { (42,666) }; my ($a,$b) = foo; say $a; say $b
camelia 42
666
lizmat src/Perl6/Grammar.nqp :-) 17:00
there have been several modules trying to do that
raku.land/github:raku-community-mo...l6::Parser would be one of them
ph88 is it good ?
lizmat alas, the author is no longer with us :-( 17:01
ph88 he died ?
lizmat yeah :-(
ph88 awww
no syntax highlighting on raku land website o_O
lizmat rakudoweekly.blog/2020/03/16/2020-...od-friend/ 17:02
ph88 ill read that
i heard raku has good grammar feature .. does that automatically yield a parser and printer ?
only 50 years 17:03
lizmat docs.raku.org/language/grammar_tutorial
yeah, way too early :-(
ph88 lizmat, thanks for the link .. though i don't see something about printer there 17:04
lizmat I'm not sure what you mean with "printer" ?
ph88 a function that takes a syntax tree and outputs a string of source code 17:06
ph88 lizmat, ^ 17:13
ph88 what's the difference between raku.org and rake.land ? 17:30
lizmat raku.land shows the modules that you can download for Raku programs
raku.org is the main website for the Raku Programming Language 17:31
Nemokosch raku.land is a comprehension of modules
guifa ph88: all you'd need to do is create a .Str method for each element of a your syntax tree. The complexity of it would be based on how pretty you want the output to be. 17:45
For instance, the upcoming RakuAST feature gives each node a DEPARSE method, that produces Raku source code from the syntax tree. I've got a module Pretty::RAST that works similarly, but tries to give colored highlighting, etc too (though mine doesn't provide complete coverage of all nodes yet) 17:46
lizmat guifa: please note that the DEPARSE method is only guaranteed to produce a string that will re-create the given node, *not* the code that was originally used! 17:54
guifa lizmat indeed — I'm guessing it was designed mainly for why i made Pretty::RAST: much faster visualization of what's going on than reading a massive list of node names 18:04
guifa can envision the python people "you mean you don't have one syntax for one parse tree and vice versa? the horror!" as we all smile and let out a maniacal laugh 18:14
ph88 thanks guys 18:39
qorg11 What happened to p6doc? 19:02
El_Che rakudoc 19:07
Nemokosch something got added 19:19
raku.land/github:Raku/p6doc
Xliff m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles /\ 21:53
camelia ===SORRY!===
Unrecognized regex metacharacter \ (must be quoted to match literally)
at <tmp>:1
------> { 3 }; }; class B { has A $!a handles /\⏏<EOL>
Regex not terminated.
at <tmp>:1
------> { 3 }; }; class B { has A $!a h…
Xliff m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles /\w+<?{ $/.Str ne 'c' }>/ = A.new; method a { 'a' }; method b { 'b' }; }; 21:54
camelia ( no output )
Xliff m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles /\w+<?{ $/.Str ne 'c' }>/ = A.new; method a { 'a' }; method b { 'b' }; }; A.new.c.say; B.new.a.say; B.new.c.say; 21:55
camelia 3
No such method 'c' for invocant of type 'B'. Did you mean any of
these: 'a', 'b'?
in block <unit> at <tmp> line 1

a
Xliff m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles /\w+<?{ $/.Str ne 'c' }>/ = A.new; method c { 'c' }; }; A.new.c.say; B.new.a.say; B.new.c.say;
camelia 3
1
c
Xliff Nice!
Is there a faster way to do that bit of delegation without the regex?
vrurg Xliff: pre-build a list of methods at compile time? 22:07
Util m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles * = A.new; method c { 'c' }; }; 22:13
camelia ( no output )
Util m: class A { method a { 1 }; method b { 2 }; method c { 3 }; }; class B { has A $!a handles * = A.new; method c { 'c' }; }; A.new.c.say; B.new.a.say; B.new.c.say;
camelia 3
1
c
Util Xliff: Delegate everything, and any explicit methods of the B class override the delegation.
Xliff Util: Ah. OK. 22:19
Util m: my @subs = sub {$^a + $^b}, (* + *), &[+], sub {$^a ~ $^b}, (* ~ *), &[~]; for @subs -> &s { say (0, 1, &s ... *).head(5) }
camelia (0 1 1 2 3)
(0 1 1 2 3)
(0 1 1 2 3)
(0 1 01 101 01101)
(0 1 01 101 01101)
(0 1 01 0101 01010101)
Util I expect output lines 1,2,3 to be identical, which they are.
I expect output lines 4,5,6 to be identical, but 6 differs from 4&5. Why?
elcaro Util: my instinct is it would be some kind of confusion with arity/count 23:06
just had a quick look, `&[+].count ~~ 2`, but `&[~].count ~~ Inf`... so that's odd 23:08
maybe something to do with it
m: say (sub {$^a + $^b}, (* + *), &[+], sub {$^a ~ $^b}, (* ~ *), &[~])».count 23:10
camelia (2 2 2 2 2 Inf)
elcaro dunno why the concat infix needs infinite arity 23:12
m: say &infix:<~>(< foo bar baz >)
camelia foobarbaz
[Coke] waves 23:15
elcaro so your sequence with &[~] is actually slurping all previous vals.
m: (0, 1, -> *@a { [~] @a } ... *).head(5) # essentially
camelia ( no output )
elcaro m: say (0, 1, -> *@a { [~] @a } ... *).head(5) # essentially
camelia (0 1 01 0101 01010101)
elcaro I've used a slurpy param on a sequence before to do dynamic programming... been meaning to write a post on it. 23:16