🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
guifa2 How does one make an native array of arrays? 01:21
m: my array @a = (my int @ = 0,1,2); say @a.WHAT 01:22
camelia Type check failed in assignment to @a; expected array but got Int (0)
in block <unit> at <tmp> line 1
guifa2 m: my int @foo = my int @ = 1,2,3;
camelia ( no output )
guifa2 m: my int @a = my int @ = 1,2,3; say @a.WHAT 01:23
camelia (array[int])
guifa2 so that creates a single item native array of native arrays of ints, but with only one item 01:24
m: my int @a = (my int @ = 1,2,3), (my int @ = 1,2,3); say @a.WHAT
camelia This representation (VMArray) cannot unbox to a native int (for type array[int])
in block <unit> at <tmp> line 1
guifa2 err 01:26
my array @a = (my int @ = 1,2,3), (my int @ = 1,2,3); say @a.WHAT
evalable6 (Array[array])
guifa2 the array gets upgraded to an Array, because of the comma operator
ab5tract o/ * 08:10
anyone know whether it is possible to pass a "combined metaop" as a reference? (something like `&Z[&<+>]` or the like) 08:12
luk_v .tell Petr37 use Cro::HTTP::Client; my $resp = await Cro::HTTP::Client.get('google.com', :!follow); say "$resp.request.uri()"; 08:18
tellable6 luk_v, I'll pass your message to Petr37
luk_v .tell Petr37 cro.services/docs/reference/cro-http-client 08:19
tellable6 luk_v, I'll pass your message to Petr37
JJMerelo m: token alt-alnum { <alnum> | <alnum>.+ }; say "þ," ~~ &alt-alnum 08:23
camelia 5===SORRY!5===
Undeclared routine:
alt-alnum used at line 1

Other potential difficulties:
Useless declaration of a has-scoped method in mainline (did you mean 'my token alt-alnum'?)
at <tmp>:1
------> 3token 7⏏5…
JJMerelo m: token alt-alnum { <alnum> | <alnum>.+ }; say "þ," ~~ /<alt-alnum>/ 08:24
camelia Potential difficulties:
Useless declaration of a has-scoped method in mainline (did you mean 'my token alt-alnum'?)
at <tmp>:1
------> 3token 7⏏5alt-alnum { <alnum> | <alnum>.+ }; say "
No such method 'alt-alnum' for invocant…
JJMerelo m: my token alt-alnum { <alnum> | <alnum>.+ }; say "þ," ~~ &alt-alnum;
camelia 「þ」
alnum => 「þ」
JJMerelo m: my token alt-alnum { <alpha> |<alpha>.+ }; say "þ," ~~ &alt-alnum; 08:25
camelia 「þ,」
alpha => 「þ」
JJMerelo m: my token alt-alnum {^^ <alpha> |<alpha>.+ $$}; say "þ," ~~ &alt-alnum; 08:26
camelia 「þ,」
alpha => 「þ」
JJMerelo m: my token alt-alnum {^^ <alnum> |<alnum>.+ $$}; say "þ," ~~ &alt-alnum;
camelia 「þ」
alnum => 「þ」
JJMerelo ^^^ Not good, I guess. 08:27
committable6: releases my token alt-alnum {^^ <alnum> |<alnum>.+ $$}; say "þ," ~~ &alt-alnum; 08:29
committable6 JJMerelo, ¦releases (45 commits): «「þ」␤ alnum => 「þ」␤» 08:30
JJMerelo committable6: releases my token alt-alnum {^^ <graph> |<graph>.+ $$}; say "þ," ~~ &alt-alnum; 08:31
committable6 JJMerelo, ¦releases (45 commits): «「þ」␤ graph => 「þ」␤»
JJMerelo committable6: releases my token alt-alnum {^^ <alpha> |<alpha>.+ $$}; say "þ," ~~ &alt-alnum;
committable6 JJMerelo, ¦releases (45 commits): «「þ,」␤ alpha => 「þ」␤» 08:32
JJMerelo committable6: releases my token alt-alnum {^^ <alpha> |<alnum>.+ $$}; say "þ," ~~ &alt-alnum; 08:33
committable6 JJMerelo, ¦releases (45 commits): «「þ」␤ alpha => 「þ」␤» 08:34
JJMerelo Er
JJMerelo Well, R#3830 includes all that above. 08:36
linkable6 R#3830 [open]: github.com/rakudo/rakudo/issues/3830 [regex] Strange token alternation errors with <alnum> and <graph>
JJMerelo committable6: releases my token alt-alnum {^^ [<alpha> | <alpha>.+ | <alnum>.+] $$}; say "þ," ~~ &alt-alnum; 08:37
committable6 JJMerelo, ¦releases (45 commits): «「þ,」␤ alpha => 「þ」␤» 08:38
JJMerelo committable6: releases my token alt-alnum {^^ [<alnum> | <alpha>.+ | <alnum>.+] $$}; say "þ," ~~ &alt-alnum;
committable6 JJMerelo, ¦releases (45 commits): «「þ,」␤ alpha => 「þ」␤» 08:38
JJMerelo committable6: releases my token alt-alnum {^^ [<alnum> | <alnum>.+] $$}; say "þ," ~~ &alt-alnum; 08:39
committable6 JJMerelo, ¦releases (45 commits): «Nil␤»
JJMerelo committable6: releases my token alt-alnum {^^ [<alpha> | <alpha>.+] $$}; say "þ," ~~ &alt-alnum;
committable6 JJMerelo, ¦releases (45 commits): «「þ,」␤ alpha => 「þ」␤» 08:40
JJMerelo Added also to R#3830 08:42
linkable6 R#3830 [open]: github.com/rakudo/rakudo/issues/3830 [regex] Strange token alternation errors with <alnum> and <graph> when they are in the second part of the alternation
timotimo does Grammar::Tracer cause these problems? 09:30
JJMerelo timotimo no, I just use it to see where it fails. 09:44
timotimo and what it shows is the opposite: it does not fail, and is totally happy with the match it obtains. 09:45
timotimo ah, i did not look closely enough
cpan-raku New module released to CPAN! Math::Libgsl::RandomDistribution (0.0.2) by 03FRITH 09:51
New module released to CPAN! Sparky (0.0.26) by 03MELEZHIK
cpan-raku New module released to CPAN! JSON::Fast (0.14) by 03TIMOTIMO 09:54
ab5tract .ask masak When you get a moment, would you mind weighing in on how close the current experimental `macros` interface is to what it could/should look like post-RakuAST? I'm not planning to use anything too crazy but I am curious as well what is maybe still missing versus your/the "master plan" 11:50
tellable6 ab5tract, I'll pass your message to masak 11:50
timotimo what do you currently get passed to a macro? 11:53
timotimo m: use experimental :macros; macro test($a) { dd $a; quasi { say "hi" } }; test(1 + 2) 11:53
camelia AST.new
hi
timotimo m: use experimental :macros; macro test($a) { dd $a.^methods; quasi { say "hi" } }; test(1 + 2)
camelia (submethod BUILD (AST: :$past, *%_ --> Nil) { #`(Submethod|78116288) ... }, method incarnate (AST: $quasi_context, @unquote_asts, *%_) { #`(Method|78116864) ... }, method evaluate_unquotes (AST: @unquote_asts, *%_) { #`(Method|78116720) ... }, method …
timotimo m: use experimental :macros; macro test($a) { dd $a.^methods>>.name; quasi { say "hi" } }; test(1 + 2) 11:54
camelia ("BUILD", "incarnate", "evaluate_unquotes", "is_quasi_ast", "Str", "BUILDALL")
hi
timotimo m: use experimental :macros; macro test($a) { dd $a.^methods(:all)>>.name; quasi { say "hi" } }; test(1 + 2)
camelia ("BUILD", "incarnate", "evaluate_unquotes", "is_quasi_ast", "Str", "BUILDALL", "antipairs", "nl-out", "Map", "repeated", "AT-POS", "squish", "kv", "Seq", "combinations", "end", "Hash", "sort", "skip", "prepend", "flat", "permutations", "rotor", "hash"…
timotimo m: use experimental :macros; macro test($a) { dd $a.^mro; quasi { say "hi" } }; test(1 + 2)
camelia (AST, Any, Mu)
hi
timotimo m: use experimental :macros; macro test($a) { dd $a.^mro; quasi { say {{{ $a }}}; say {{{ $a }}} } }; test(1 + 2) 11:54
camelia (AST, Any, Mu)
3
3
timotimo you can probably only create asts using quasi? 11:55
ab5tract timotimo as in, that is the only aspect that is working in the current implementation (and it is working as expected) or that quasi should be able to create something other than AST 12:11
timotimo something other than quasi should be able to create an ast 12:12
ab5tract timotimo my question is really a bit higher level -- can I write against the experimental implementation without regard for internal details (and the fact that they are about to change)
timotimo gotcha :)
so it sounds like the short answer is "no"
timotimo actually i dunno
timotimo BBIAB 12:12
ab5tract ++ 12:13
fluca1978 hi, I'm having some difficulties in understanding what the method tree does <docs.raku.org/routine/tree>. I've understood it does call tree on the iterable or applies a whateverable, but what is the aim? 12:44
lizmat fluca1978: I've never used tree, and I think its semantics sorta became suspect after the GLR 12:46
in fact, the code in the core still carries this comment:
# XXX GLR Do we need tree post-GLR?
fluca1978 lizmat: and GLR stands for ... (I've seen the comment trying to figure out in rakudo what tree was doing) 12:47
lizmat Great List Refactor
during 2014 / 2015 it was decided that the way lists work, needed changing and harmonizing 12:48
this became the Great List Refactor, to make then Perl 6 ready for release
fluca1978 oh, I must have missed the eterogeneity before...I'm using raku only since 2017 12:49
holyghost ok, racul is portable to m68k machines, after severe modularization (which is a good thing :-) 12:50
amiga machines, I mean
ab5tract holyghost what is this racul that you speak of? :) 12:51
holyghost github.com/theholyghost2/racul (scheme language extensions for raku applications) 12:52
It's a guile but written from scratch 12:53
not using anything from guile also
ab5tract neat project :D 12:54
lizmat not a lot to see except some makefiles yet? 12:54
holyghost thx :-) 12:55
holyghost lizmat : there's a start for symbols in src/symbols 12:55
I have to think about it twice
holyghost I've been a machine lately :-) 12:59
El_Che holyghost: sent you a PR for the doc 13:03
holyghost I'll look into it later on 13:07
kawaii Are there any modules for turning large numbers of seconds into friendly hours and minutes? :) 13:14
timotimo yes
oddp There's polymod.
kawaii I literally just typed "I bet Timo knows" to my friend, and here you are :)
timotimo github.com/raku-community-modules/...Denominate 13:15
kawaii timotimo: thank you :)
oddp docs.raku.org/routine/polymod
Look at the example.
kawaii Oh this looks good too, and no additional dependency 13:16
m: my $i = 84864; say $i.polymod(60); 13:35
camelia (24 1414)
kawaii m: my $i = 84864; say $i.polymod(3600);
camelia (2064 23)
holyghost I've implemented something like that in Game-Markov 13:36
splitting off ns ms and s
for MarkovTicks
oh well 13:37
oddp m: my ($secs, $mins, $hours) = 84864.polymod(60, 60, 24); say "{$hours}h : {$mins}m : {$secs}s" 13:47
camelia 23h : 34m : 24s
oddp kawaii: ^
kawaii oddp: ah that works, thanks! 13:50
timotimo but that only goes up to hours 13:51
kawaii that's all I need in my use-case
oddp m: say 84864.polymod(60, 60, 24)
camelia (24 34 23 0)
oddp You could also get the day there. 13:52
Maybe we should include an example in the docs similar to the one here that makes it quite clear: rakuadventcalendar.wordpress.com/2...t-in-raku/ 13:56
holyghost El_Che : about your PR, you mean that raku is not perl6 std based ? 14:01
oddp It's a naming issue, nothing more, holyghost. 14:03
holyghost ok, mea culpa
right, liz said that it is named raku now
bufgixed, I won't forget next time I hope 14:10
codesections Here's a style/idiom question for the channel: when tracking a mutable count of elements, do you prefer to use a Hash that tracks the values (and modify with assignment) or a BagHash (and modify with `add`/`remove`). That is, which of these two looks better to you: 15:11
m: my %menu-items = eggs => 1, bacon => 1; %menu-items<spam> += 5; say %menu-items
camelia {bacon => 1, eggs => 1, spam => 5}
codesections m: my %menu-items is BagHash = eggs => 1, bacon => 1; %menu-items.add(<spam>) for ^5; say %menu-items
camelia BagHash(bacon eggs spam(5))
guifa2 codesections: it depends on where in my code I am :-) 15:31
The first one is closest to what I'm doing if for some reason it's clearer for me to do that during initiatilization / in the innards of module space
The latter is something I might prefer for user space (but I'd be careful whether "add"means "add to the menu" or "add quantities to an item in the menu", which if doing full OO might should be two separate commands, with the latter one issuing an exception if the item isn't on the menu) 15:34
tbrowder hi, all 15:35
codesections o/ 15:40
tbrowder question on use of mi6: its doc says the build option uses the Build.pm file if it exists. is that the same one zef uses?
codesections: g'day \o/ 15:41
codesections guifa2: thanks, that's a helpful way to think about it. You said you'd do the first "if for some reason it's clearer". What sort of things would make it clearer/less clear?
I haven't used mi6, so I can't help with that one
tbrowder okey dokey, thnx 15:42
guifa2 codesections: basically whitespacing :-) if I make the hash with really simple values (eggs 1, bacon 1, or even biscuits => $baker.check-availability('biscuits') ) I'll probably leave it all in one initial assignment line 15:43
but if the latter gets more complicated
biscuits => min($lookup-suppliers('bakers').grep(*.check-availbility('biscuits').sort(*.request-prices('biscuits')).head, 10) 15:45
It can often be much nicer visually to break that out into a separate line after the initial assignment 15:46
er there's an error in that code but you get he idea
codesections guifa2: that makes sense, except that I don't see how it relates to the choice between a Hash and a BagHash. Both are mutable, so both let you split it into multiple lines if need be 15:51
guifa2 ah, sorry, I was focusing on the .add semantics ;-) 15:52
codesections Oh, I see. So, you're saying you generally disfavor using `+=` – if you think you'll need to modify the state, you'd like to have a `.add` method and let the type manage its state in a more OOP way? 15:53
guifa2 It makes sense to me from a user perspective — they don't need to know how your menu works internally. And maybe down the road, you want to change how the menu is stored internally. If you're using add, that's a lot easier since method add($) is easy to make. You *could* still pull it off mimicking Hash's %foo<bar> += 5 using Proxies but it's more work 15:57
codesections Thanks, that all makes sense and is a helpfully different perspective than how I was thinking about it :) 15:59
I was thinking about it more in terms of type constraints: if I have a BagHash, I can't later try to set a key equal to something other than an Int or do any of the weird/powerful things I'd be tempted to do with a plain Hash 16:00
(which is getting at a similar point as part of what you said, but your point about extensibility is a bit different – but points in the same direction) 16:01
guifa2 can you tell I'm someone who mainly does module authoring? lol 16:14
codesections :D It's a good perspective to have. So many one-off, we'll-throw-it-away-soon scripts end up becoming larger than expected, and early design decisions can come back to haunt people 16:15
e.g., tabs in Makefiles 16:16
Kaiepi how is endianness handled by blobs? 16:18
eh, ig this is something i can test with nativecall 16:23
holyghost added amiga vbcc makefile to racul :-) 16:28
Now for the C code, but that's for later 16:30
holyghost is a bit afk 16:31
guifa2 Kaiepi: endianness doesn't feel 100% fleshed out to me. if you use Blob[uin64], I believe it defaults to your system's endianness
there's the read methods on blob8 that let you specifiy endianness, but not on writing 16:32
Kaiepi it seems like the byte order depends on backend 16:56
on the jvm, it seems to be big endian instead of native byte order 16:57
timotimo you need to use a buf8 and .write-uint64 and friends that take endianness 16:58
holyghost I drink only in the evening now, I'm super more productive, which makes me far more happy than calming down with beer. just my 2 cents
timotimo there are no write methods on blobs, because blobs are read-only, i would assume 16:59
guifa2 I'm surprised that the blobs don't have endianness as an attribute 17:01
timotimo that would only do anything when you're writing to files and other byte-oriented streams, right? 17:02
holyghost FWIW, C read and write functions are char based, e.g. WAV headers need endianess 17:04
I dunno for nqp though
aciinum or alphanum functionality 17:06
*ascii num
which you shift << 8, << 16 << 24 for endianess 17:07
or the other way round
32 bits not 64 17:08
or 36
holyghost or a byte in mono (C#) 17:10
guifa2 timotimo: I don't remember the exact details since I don't tend to work a huge maount with binary stuff (but am increasingly looking to do so for performance in intl::) but when I was making binex I remember having a lot of trouble knowing — from a programatic sense — if a blob that was passed to a sub was big or little endian 17:11
An endian-ness doc (with where things are done transparently to the user and where the user needs handle it manually) would be pretty sweet 17:12
jdv79 maybe someday someone will do a thing with/on raku at the hope conf 17:16
jdv79 maybe a lightning talk 17:16
lucasb What's a easy way to code the utility function 'factor(360) -> (2, 2, 2, 3, 3, 5)' ? I was hoping for a Int.factor method to exist. Wouldn't it be useful? :) 18:50
SqrtNegInf rosettacode.org/wiki/Prime_decomposition 19:00
[Coke] m: sub factor($n) { my $r = $n; gather for 2..sqrt($n).Int { while $r %% $_ { $r/=$_ ; take $_ } } } ; say factor(360) 19:09
camelia (2 2 2 3 3 5)
tellable6 2020-07-27T07:45:24Z #raku-dev <JJMerelo> [Coke] I was going to, but it's apparently disappeared? 19:10
[Coke] ^^ shorter, but very likely not performant with bigger numbers.
[Coke] oops. lost my prime listing. 19:16
[Coke] m: my @primes = (2..Inf).grep(*.is-prime); sub factor($n) { my $r = $n; gather for @primes { while $r %% $_ { $r/=$_ ; take $_ }; last if $r==1 } }; say factor(360); say factor(123456789) 19:20
camelia (2 2 2 3 3 5)
(3 3 3607 3803)
lucasb thanks! SqrtNegInf, [Coke] 19:46
SqrtNegInf There's also the module Prime::Factor (it implements the 1st example at rosettacode.org/wiki/Prime_decomposition#Raku). Best of both worlds: runs quickly, easy to call. 19:48
moritz m: sub f($i) { (^$i).map({ return $_ }) }; say f(2) 19:54
camelia Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block <unit> at <tmp> line 1
moritz oops, reacting to stale backlog :D 19:55
gfldex lolibloggedalittle: gfldex.wordpress.com/2020/07/27/ha...g-failure/ 20:17
Geth ¦ problem-solving: vrurg assigned to jnthn Issue Do we need :desc named in Test routines? github.com/Raku/problem-solving/issues/215 20:38
lizmat and another Rakudo Weekly News hits the Net: rakudoweekly.blog/2020/07/27/2020-...t-on-time/ 20:50
holyghost yay!
holyghost reads it 20:52
I'm going to study Hungarian
Xliff o/ 20:59
oddp Thanks a lot, liz! 21:00
holyghost 'lo Xliff 21:01
Xliff gnolly
holyghost I've put some scheme projects on the server, gondolinX.tar.gz files
busy sorting those out 21:02
too bad scsh does not run on 64 bit systems
so you cannot run them there
melezhik lizmat - thanks for yet another rakudo weekly, as usual - good content! 21:19
lizmat thanks to all the people providing that content! :-)
guifa2 lizmat: that's a cool random name module 21:19
melezhik lizmat - sure! 21:20
lizmat thank you, another cool module I made the past weeks, Hash2Class needed it
guifa2 internationalizes it, 'say docker-name :lang<es>' # quijote-épico
;-)
holyghost szendvics 22:43