🦋 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.
tbrowder .tell yary fun briefing! 00:08
tellable6 tbrowder, I'll pass your message to Yary
moon-child thoughts on adding ∊ as an alias for ∈? 00:11
guifa I feel like the discussion had come up once about doing some aliases like that and the result of the discussion was folks weren’t keen on it 00:56
tech_hutch Hi 01:29
Does Raku have any form of destructuring/unpacking?
Xliff vrurg: You still around? 01:46
vrurg Xliff: kind of. 02:06
Xliff vrurg: OK. If you have some time, I'd like to talk adding candidates to proto. 02:08
This is to hopefully... finally... address the lingering issues with Method::Also
So I have a HOW that I want to pun to an object to overide its normal behavior, particularly incorporate_multi_candidates. 02:09
vrurg Xliff: time is the problem. :( But hopefully, I'll manage. 02:10
Xliff However I need to make sure that 1) the aliased proto is added and 2) all of the aliased candidates are added.
This is what I currently have, now. 02:11
github.com/Xliff/Method-Also/blob/...so.pm6#L57
I suspect much of that is out of date.
Since time is a factor, just a quick looksee would be appreciated.
But will probably need more of your time when available. 02:12
TIA
vrurg Somehow I suspect that you can actually just clone the originals, change their names, and push back to multi_methods_to_incorporate before invoking the original incorporate_multi 02:14
Xliff: have you tried this approach?
Xliff Not tried, no. Was thinking something similar, yes. 02:15
That's a thought. I'll preserve this and try that in the main branch. 02:16
@!multi_methods_to_incorporate is just an array with (.name, .code) pairs, right?
Or... maybe just method objects? 02:17
vrurg Xliff: consider RoleToRoleApplier or RoleToClassApplier in src/Perl6/Metamodel 02:18
looks like it's an object. 02:19
It's an object of internal class MultiToIncorporate 02:20
It has only .name and .code on it.
Xliff It's internal? :S -- can I get access to that from the HLL? 02:21
vrurg Xliff: you don't need to know a class to work with its instances. 02:24
tech_hutch Hey guys, sorry to interrupt you, but how do you pass a class constructor to another function? I've tried various ways of using `&`, but it doesn't seem to work.
Xliff OK, so add_multi_method should do what I need?
vrurg: OK, thanks. I'll create another branch and let you know how it goes. 02:25
vrurg Xliff: I think it must. 02:26
add_multi_method, I mean.
tech_hutch: use Class.^lookup("new"), but normally you don't need it. If you see yourself in need to do so then either you do some very low-level, or you do something wrong. :) 02:27
tech_hutch Hm, okay
vrurg tech_hutch: really, why?
tech_hutch I'm just trying to parse every line of a file into a class
I'll gladly hear a more idiomatic way to do that lol 02:28
vrurg Ok, then all you need the class typeobject.
tech_hutch What do you mean? Use the type as a function? 02:29
vrurg m: sub foo(Any:U \class) { class.new }; class Foo {}; say foo(Foo).WHICH
camelia Foo|72327024
tech_hutch Oh, I actually don't need to do it dynamically. I just didn't want to have to make a lambda just to call the constructor 02:30
vrurg `class` is a bad name for a parameter, actually. But otherwise...
tech_hutch I'm basically doing `"some_file".IO.lines.map: -> $line { Class.new: $line }` 02:31
vrurg Performance? 02:32
Or what's the reason to avoid a closure?
tech_hutch I'm not really concerned about performance, I just wanted to see if there was a way that looks nicer lol
vrurg I don't think that 'my &c = Class.^lookup("new"); .map: &c(Class, $line)' would look any better. Most certainly, it'd complicate reading the code. 02:36
m: my @a = 1,2,3; class Foo { has $.v; multi method new($v) { self.new(:$v) } }; my Foo() @b = @a; say @b 02:37
camelia [Foo.new(v => 1) Foo.new(v => 2) Foo.new(v => 3)]
tech_hutch Yeah, that's not great
I'll just stick with what I have
vrurg tech_hutch: you can try coercion.
tech_hutch Oh?
vrurg 'class Class { method new($attr) { self.new(:$attr) } }; my Class() @converted-lines = $handle.lines' Should work 02:39
tech_hutch Wow, it actually does! 02:41
What interesting syntax
vrurg tech_hutch: For safety you could even use Class(Str:D) to avoid accidental acceptance of undefineds or unsupported type. 02:43
tech_hutch I see
guifa2 tech_hutch: when you say destructuring/unpacking you mean like in signatures or Java's serializable? 05:15
tellable6 guifa2, I'll pass your message to tech_hutch
Geth ecosystem/alabamenhu-patch-2: f2cb7283b5 | L'Alabameñu++ (committed using GitHub Web editor) | META.list
Add Intl::Format::Number to ecosystem

  (can we get it on the first try this time?)
07:36
ecosystem: alabamenhu++ created pull request #575:
Add Intl::Format::Number to ecosystem
Geth doc: 75d5b04334 | (Stoned Elipot)++ (committed by Juan Julián Merelo Guervós) | 2 files
lastcall is an independent routine ref #3767
10:03
linkable6 DOC#3767 [open]: github.com/Raku/doc/issues/3767 [docs] lastcall is most probably in the wrong place
Geth doc: stoned self-assigned lastcall is most probably in the wrong place github.com/Raku/doc/issues/3767
30db88bdce | Coke++ | doc/Language/modules.pod6
11:41
Doc_Holliwood Is it possible to inspect/change what has been gather-ed from within the block? 12:50
notagoodidea is it a performance cost between `slurp` and `IO.lines`? 13:26
notagoodidea ok, `slurp` seems faster (17s vs 28s for 100_000 times to open the same files) 13:35
moritz yes, it has to do less 15:50
moritz lines needs to read *and* search for newlines 15:50
notagoodidea Is slurp lazy or it will hang on very large files? 15:53
Xliff moritz: Hi. Can you help me figure out why my slang keeps running into the 'two terms in a row' rule? 15:58
repl.it/@Xliff/FrayedAnxiousSweeps...#main.raku
m: my @a = gather for <1 2 3> { take $_; @a.gist.say } 16:02
camelia []
[]
[]
Xliff m: my @a = gather for <1 2 3> { take $_; @a.gist.say }; @a.gist.say;
camelia []
[]
[]
[1 2 3]
Xliff Doc_Holliwood: ^^ Looks like that's a no. 16:03
tellable6 Xliff, I'll pass your message to Doc_Holliwood
Xliff Doc_Holliwood: re: your gather/introspect question
tellable6 Xliff, I'll pass your message to Doc_Holliwood
guifa2 notagoodidea: slurp is not lazy, lines is though 16:29
[Coke] tony-o: question about fez. Does it have a literal "META" file? or might the docs that were recently added to raku/doc be referring to the modules META6.json file? 16:34
github.com/Raku/doc/blame/master/d....pod6#L920 16:35
(found by running the xt/ tests in raku/doc, it doesn't like "META" as a standalone) 16:37
[Coke] has a patch coming assuming it's the raku META6.json and also addresses issues found with xt/aspell.t 16:43
doc: 7a25604eaa | Coke++ | 2 files
Track new words
linkable6 Link: docs.raku.org/language/modules
codesections just to make sure I'm not missing something obvious: There's no idiomatic way to bulk-export the `our` scooped variables in a module, is there? It feels really verbose to keep writing `our sub ... is export`, but that _is_ the accepted way to do it, right? 16:55
codesections (I know I could do something fancy with `sub EXPORT` but my understanding is that this isn't very idiomatic and, in any event, would still be verbose. But I'd love to hear that I'm wrong on either count!) 16:57
guifa2 codesections: maybe something like sub EXPORT { OUR::.Map } 17:30
OUR:: is a hashy stash of all the our-scoped symbols. sub EXPORT needs to produce a Map of symbol-name + symbol value, and … that's exactly what .Map gets you :-) 17:32
codesections guifa2: yeah, I was wondering about something like that. Or maybe just putting the exports inside a `my package EXPORT::DEFAULT {...}` block? 17:34
guifa2 yeah. I'm curious though, what are you doing with lots of ours and exports? I tend to use either/or rather than both 17:35
codesections hmm? Maybe I'm confused... I thought that exported variables need to be `our` scoped unless you want the consumer to need to type out the whole module name on each use. Am I wrong about that? 17:38
guifa2 hmm oh I guess you do have to our scope them, huh. my bad. (tbh I think I almost always use sub EXPORT for variables) 17:44
sam21 commit: HEAD for 1..20 -> $i {CATCH {default { say "Error ",$i;next}} my @list = 0 xx $i; for @list Z @list -> $a, $b {}} 17:45
committable6 sam21, gist.github.com/f9a671e3464b09e92b...4ee6ccd689
sam21 commit: HEAD for 1..20 -> $i {CATCH {default { say "Error ",$i;next}}; my @list = 0 xx $i; for @list Z @list -> $a, $b {}} 17:45
committable6 sam21, ¦HEAD(65a5cce): «Error 1␤Error 3␤Error 5␤Error 7␤Error 9␤Error 11␤Error 13␤Error 15␤Error 17␤Error 19␤»
sam21 Hello, I don't understand why the code above fail for every list with odd number of elems. Is this normal? 17:48
timotimo the Z operator will iterate until the shortest of the lists has ended
guifa2 it's because of the pointy block 17:50
-> $a, $b requires two arguments to be produced 17:51
sam21 commit: HEAD say (1,2,3) Z (1,2,3) 17:52
committable6 sam21, ¦HEAD(65a5cce): «((1 1) (2 2) (3 3))␤»
guifa2 With ^3 the first time you get (1,1) and (2,2), the second time you get (3,3) and … error
If you're wanting $a to 1, and $b to be 1, use deconstruction 17:53
m: for <a b c> Z <1 2 3> -> ($a, $b) { say "letter $a, number $b; " }
camelia letter a, number 1;
letter b, number 2;
letter c, number 3;
sam21 Thank you both, I don't know about deconstruction but i will look at the doc 17:54
Ok parenthesis! 17:57
tbrowder .seen thundergnat 18:24
tellable6 tbrowder, I saw thundergnat 2021-01-07T17:00:34Z in #raku: <thundergnat68> >[Coke] Is there interest in having a sort algorithm like tcl's [lsort -dictionary]? Perhaps something like modules.raku.org/search/?q=Sort%3A%3ANaturally ?
tbrowder .tell thundergnat Base::Any is awe-inspiring! 18:25
tellable6 tbrowder, I'll pass your message to thundergnat68
moritz Xliff: sorry, I have zero experience with slangs 18:28
guifa2 Xliff: I actually recently did a slang very similar, I'll try to recreate and test it later today 18:29
[Coke] guifa2: you can add a ? to make the last one optional. 18:41
m: for <a b c> -> $a, $b? { say "$a $b" }
camelia a b
Use of uninitialized value element of type Mu in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
c
in block at <tmp> line 1
[Coke] m: for <a b c> -> $a, $b? { dd $a, $b }
camelia "a"
"b"
"c"
Mu
codesections is there any way to write a signature for a named argument that accepts Positionals and converts non-positionals -- and that still uses `@`? 18:49
I'd like to do something like this:
m: sub f(List() :$a) { dd $a }; f("foo") 18:50
camelia Too many positionals passed; expected 0 arguments but got 1
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
codesections m: sub f(List() :$a) { dd $a }; f(:a('foo'))
camelia $("foo",)
codesections but use `@` (since the argument always _will_ be positional) 18:51
[Coke] codesections: I don't know of a way to do that, and it seems like a code smell. 18:54
if you want to do it, you can do it yourself at the top of your routine. 18:55
codesections [Coke]: Thanks. That's interesting -- what about it strikes you as a code smell? 18:56
(my sense is that a lot of the built-in functions accept either a List or a single arg (instead of requiring the caller to pass in a one-element List, and I usually try to do the same in the name of dwim)Thanks. That's interesting -- what about it strikes you as a code smell? 18:58
[Coke] because those are two different types of args and conflating them seems very surprising. 18:58
if you want two different styles of args, there are multis. 18:59
but if you want named to be treated as positionals... why not just used positionals?
s/used/use/
codesections good point re: multis 19:00
codesections [Coke]: as to the "why" part of your question, just for ergonomics. Consider the Hero class example at docs.raku.org/type/Attribute#method_gist That has a signature of (:$name, :@inventory), which means that a caller has to do something like `Hero.new(:name<Bob> :inventory(($the-sword,),))` if they want to create a hero with only one item in their inventory. But it's clear we wouldn't want to make :inventory into a positio 19:14
parameter
notagoodidea I was looking at the source of RUN-MAIN and view : github.com/rakudo/rakudo/blob/65a5...in.pm6#L55 about the `coerce-allomorphs-to` option. I don't see any trace of it in the documentation (yet?) 19:23
codesections I guess a different way to put what I was saying is that, given that this works: 19:32
m: sub g(*@a) { dd @a }; g(0);
camelia Array element = [0]
codesections I don't understand why this doesn't:
m: sub f(:$a (*@b)) {dd @b}; f(:a(0))
camelia Cannot unpack or Capture `0`.
To create a Capture, add parentheses: \(...)
If unpacking in a signature, perhaps you needlessly used parentheses? -> ($x) {} vs. -> $x {}
or missed `:` in signature unpacking? -> &c:(Int) {}
in sub f at <tmp> l…
19:33
[Coke] ah. you want slurpy named? that's not how I read your ask. 19:36
[Coke] (my bad) 19:37
codesections well, I didn't either :) It took a bit more playing around to realize that's what does what I want 19:38
Xliff guifa2: Thanks. 19:42
moritz: Ah, Ok. 19:43
[Coke] can't you just use :$a ?
m: sub f(:$a) { dd $a} ; f(:a(0)) ; f(:a<0 1 2 3 4>)
camelia 0
$(IntStr.new(0, "0"), IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3"), IntStr.new(4, "4"))
[Coke] m: sub f(:$a) { dd $a[]} ; f(:a(0)) ; f(:a<0 1 2 3 4>) 19:44
camelia 0
(IntStr.new(0, "0"), IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3"), IntStr.new(4, "4"))
codesections [Coke]: yeah, you can (and that's what I'm doing). That doesn't nicely convert `0` into `(0,)` for you, and you give up the @ sigil signal that you're dealing with a list. 19:46
codesections you can fix the first with `sub f(List() :$a)`, but then you're in the odd place of having a $ variable that is _always_ a @ type 19:47
which is what made me curious if I was missing something 19:48
[Coke] let us know if you find it. :) 19:50
codesections will do :)
thundergnat tell tbrowder: Glad you find it useful, or awe-inspiring at least. :-) 19:54
tellable6 2021-01-10T18:25:56Z #raku <tbrowder> thundergnat Base::Any is awe-inspiring!
thundergnat meh
.tell tbrowder: Glad you find it useful, or awe-inspiring at least. :-)
tellable6 thundergnat, I'll pass your message to tbrowder
notagoodidea m: multi sub f(:@a){dd @a}; f(:a<0 1>); f(:a<0>)
camelia (IntStr.new(0, "0"), IntStr.new(1, "1"))
Cannot resolve caller f(:a(IntStr)); none of these signatures match:
(:@a)
in block <unit> at <tmp> line 1
tbrowder well, it's so much better than my Number::More I'm thinking of retiring it 19:56
Xliff Base::Any?
tbrowder yes
tbrowder mine was more an exercise in how to do it rather than utility, but it (Nd Base::Any do have utility when trying to have unique but ordered ids for databases. they enable smaller widths for large numbers 19:59
at least visually 20:01
Xliff Ah. Base::Any looks nifty.
Might make it easy to do spreadsheets.
thundergnat To be honest, Base::Any started out as routines I wrote to solve Rosettacode tasks. Once I nailed them down I just collected them all together and stuck them in a module. 20:02
tbrowder how so?
thundergnat Figured if I spent so much time figuring them out, may as well make them easily available to others.
tbrowder spreadsheets, that is
Xliff Columns
tbrowder ah, i forgot about that, i usually use the integer rep 20:03
Xliff Yeah. 20:04
Still fresh, so I'm testing it out.
thundergnat Actually... most of my modules started out that way. 🤔 20:05
Xliff raku -e 'use Base::Any; set-digits("A"..."Z"); say 26.&to-base(26)' # BA (?) 20:07
Xliff 25 is Z 20:07
That's odd.
thundergnat A is 0
thundergnat Any standard base does not have a 'digit' in that base. 20:09
Just like base 2 doesn't have a digit 2 20:10
Xliff OK. That kinda makes it difficult to go from A = 1 to AA = 27
Still neat, though.
Better use might be a RYO crypto tool.
Geth doc: d4887a5d6d | (Stoned Elipot)++ | 2 files
[skip ci] Add GitHub workflow to run tests from t/

  ... with the help of a companion script running the tests in a container
with the image jjmerelo/perl6-doccer.
ref #3777
20:13
linkable6 DOC#3777 [open]: github.com/Raku/doc/issues/3777 [docs] We need to speed up tests or otherwise reduce dependence on Travis
thundergnat raku -e'use Base::Any; set-digits( flat "🦋", "A"..."Z"); my @cols = lazy flat Any, (^∞).map({.&to-base(27)}).grep( !*.contains("🦋")); say @cols[$_] for 1..5; say @cols[24..29];' 20:55
Xliff ^^^
Xliff Hah! Odd. I did consier using base 27. 20:58
thundergnat++ # Thanks
O I C how that works, now. 21:00
Xliff thundergnat: Now how about doing that in reverse? ];-D 21:02
thundergnat ?? maybe something like: @cols.first: * eq 'FD', :k; 21:04
moritz or just @cols.first: 'FD', :k;
smart-matching with a string does string equality comparison 21:05
thundergnat err, yeah, what moritz++ said.
Xliff LOL! True enough.
Xliff Can roles take an optional parameter? 21:18
Or a named parameter? 21:21
stoned75 docs.raku.org/language/objects#Par...ized_roles
gfldex Xliff: they take named, slurpies and mandatory named. Not sure about optional. 21:25
m: role R[$p?] { has $.a = $p };
camelia ( no output )
gfldex m: role R[$p?] { has $.a = $p }; class C does R {}; C.new.a.say; 21:26
camelia (Mu)
gfldex m: role R[$p? = "default"] { has $.a = $p }; class C does R {}; C.new.a.say;
camelia default
gfldex Xliff: they do :)
Xliff gfldex: Thanks! # gfldex++ 21:28
Geth problem-solving/solution-250: 825db3d8b1 | Altai-man++ | solutions/documentation/search-categories.md
Provide a solution document for github.com/Raku/problem-solving/issues/250

  "Documentation search categories are not standartized"
Fixes github.com/Raku/problem-solving/issues/250
21:30
melezhik Hi I've a playground for Sparky CI - lightweight CI server written on Raku. 161.35.142.50/ Here you can find example projects for some Raku modules. If someone is interested to experiment/play with - let me know ... Sparky could be self - hosted easily and could be a good alternative to Travis that have recently limited support of open 21:41
source projects ...
perry Snazzy domain name. 21:44
;-)
melezhik it's playground so far and the main idea - self-hosted, everyone could spin it up easily ... 21:45
notagoodidea zef 22:10
oupsy
cog The Rakudo INSTALL.md mentions a parallel test but no parallel build. What is the the incantation with parallel build of MoarVM 22:29
Perl Configure.pl does not help either 22:31
That would translate in make -j win the respective folders 22:36
Solved by setting envier to MAKEFLAGS=-j 22:40
notagoodidea mm, you can't call "nqp" from the REPL? I call "use nqp;" and after ":qp::istrue(True)" return "Could not find nqp::istrue, did you forget 'use nqp;'". 22:44
m: use nqp; nqp::istrue(True);
camelia ( no output )
notagoodidea m: use nqp; say nqp::istrue(True); 22:45
camelia 1
notagoodidea it is with rakudo v2020.12 from rakudo-pkg. 22:46
notagoodidea Oh. The import of modules in the REPL is not permanent but only available for the ongoing line. 22:48
"use nqp; say nqp::istrue(True);" works but not spread in two lines. 22:49
is it the expect comportment for the REPL? 22:50
gfldex The REPL got quite a few limits. Raku is a lot less dynamic that it might seem at first. 22:51
notagoodidea May you say more because with a compiled language like OCaml the REPL experience is quite good. 22:55
gfldex Rakudo will use early binding when it can and then inline whereever possible. 22:58
gfldex If you spread a routine across multiple lines the REPL tries to maintain scope and that is buggy. 22:59
notagoodidea I don't connect the done between this and the limit of the REPL?
oh. 23:00
bigdata Does raku better support ML and other stuff python is good for? 23:38
How does raku compare to python? 23:40
notagoodidea I don't have seen the binding to the usual lib but the use of NativeCall seems to make it easier to build around wrapping and binding to C/C++/Fortran libs. 23:43
The ecosystem is way younger and does not benefit from the same amount of energy put in by the larger python community. 23:44
notagoodidea But you can call python from raku via Inline::Python 23:44
On the language level, it is very different on the surface and under it. Depends on what you look for in term of usage and in general. 23:45
But if you want to go the ML/Big Data/Heavy Calc, Julia is a better call imho and you can also call Python and R via Julia with similar libs than Inline::Python in Raku. 23:46
bigdata: what do you have in mind?
bigdata i believe you have answered my question
notagoodidea Yep after it depends what you call "ML & stuff". 23:48
Whipping PyTorch, Tensorflow etc., I have not seen Raku binding around but I did not look after also (and I am pretty new to the language). 23:49
Crunching some BigInt, I think that when the support for BigInt gonna move from tommathlib to GMP, it is gonna be better. 23:50
notagoodidea After, it depends, I used to be on geodata dance and I can easily whip a Postgres+Postgis install put raku in front and play with that. 23:51
Maybe not doing bayesian inferance on gespatial data but besides R, a bit Python and Julia, I don't know any language with enough library to make it easy. 23:52
guifa2 ATM I haven't seen much work done on ML in Raku — but I have a project that in the next year or two will benefit greatly from it, and so I may look to create bindings 23:53
notagoodidea An idea which lib you may target? 23:54