🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
cfa github.com/rakudo/rakudo/issues/5165 00:00
can probably be retitled and clarified by someone more knowledgeable than me 00:01
jaguart docs show using `submethod BUILD ( :$!x ) { }` to automagically populate private $!x -> is there a variant that binds? Or do I have to `submethod TWEAK (:$x ) { $!x := $x }` 00:16
Nemokosch this is what I'd call a "vrurg question" 🙊 00:21
vrurg jaguart: `has $.foo is build(:bind)` should do it. 00:23
jaguart nice - that works if I have no BUILD submethod, but not if I do have a BUILD 00:30
jaguart so no need at all BUILD on a private attribue - :)) 00:31
m: -> {}.Str.say 00:52
camelia Block object coerced to string (please use .gist or .raku to do that)

in block <unit> at <tmp> line 1
jaguart is there any way to test if something can .Str ? 00:53
m:say -> {}.^can('Str')
evalable6 (Str Str)
jaguart I mean can .Str without emitting warnings on STDERR :)
I mean can .Str without emitting warnings on STDERR :) 00:54
Nemokosch this worked though, no? 00:58
there is also .?Str, as in "do if you can, return Nil otherwise" 01:01
rf m: say (do if "".Str { 'yes' } else { 'no' }); 01:02
camelia no
rf m: say (do if "".^can("Str") { 'yes' } else { 'no' });
camelia yes
rf Forgot the .^can like a dingus
vrurg jaguart: moreover, avoid using BUILD whatsoever unless you KNOW what you're doing. 01:08
jaguart I can do that! 01:13
rf Is there any way to do introspection on an variable name? 01:14
Something like: my $hi = "abc"; $hi.^var-name -> "hi"; 01:15
jaguart m: my $a = 4; say $a.VAR.name
camelia $a
rf Oh sweet, thanks! 01:16
I had the goofy idea to write a CSS library in Raku and use the variable name as class if you don't specify 01:17
jaguart not so good for subs/methods though as their internal .VAR.name may not match their name in the caller
in: class Foo { has $.bar = 42 } -> is there any introspection that tells me the Attribute's default value? i.e. the 42? 01:23
Nemokosch it doesn't make things easier that this is not a "default value" in the same sense has Int $.bar would have the default value of (Int) 01:35
I think has $.bar = 42 is actually like my $bar = 42 - 42 has no special relevance 01:38
has $.bar is default(42) would be different 01:39
rf Here's a trick to find the default value :^) 01:46
m: class Foo { has $.bar = 42 }; Foo.new.bar.say; 01:47
camelia 42
Nemokosch 🧠 01:53
jaguart m: class C { has $.x is rw = 42 }; my $a = C.new; $a.x.say; $a.x = Nil; $a.x.say; my $b = C.new; $b.x.say 02:02
camelia 42
(Any)
42
jaguart so it acts as a constructor default
the is default(42) is used whrn an Attr is assigned Nil
m: class C { has $.x is rw is default(42) }; my $a = C.new; $a.x.say; $a.x = Nil; $a.x.say; my $b = C.new; $b.x.say 02:03
camelia 42
42
42
rf It's not a constructor default, it's a fallback 02:17
I believe
m: class C { has $.x; method new(:$x = 123) { $!x = $x; } }; say C.new.x; say C.new(x => 3); 02:19
camelia Cannot look up attributes in a C type object. Did you forget a '.new'?
in method new at <tmp> line 1
in block <unit> at <tmp> line 1
rf Maybe new has to be BUILD 02:20
jaguart Seems to act as the initial value for the attr when the object is instantiated 02:24
I would expect if you provided defaults in methods like TWEAK et al that they would apply after this
rf Makes sense. 02:25
jaguart m: class C { has $.x is rw = 42; submethod TWEAK ( :$x = 123 ) { say $!x; $!x = $x; } }; C.new.x.say 02:27
camelia 42
123
jaguart this works 02:34
m: class C { method new ( Mu \x ) { say x } };C.new( <b> )
camelia b
jaguart m: class C { method new ( Mu \x ) { say x } };C.new( :a<b> )
camelia Too few positionals passed; expected 2 arguments but got 1
in method new at <tmp> line 1
in block <unit> at <tmp> line 1
jaguart why does passing a pair in not?
tonyo it's trying to match a named param 02:35
jaguart new has an ary of 1?
tonyo it expected two arguments and got one, expected (CLASS, Mu) but got (CLASS, :a) 02:36
jaguart oh - so ignoring the pair as if it were an optional named arg 02:37
tonyo m: class C {method new (Mu \x=1, *%_) { say x; say %_; } };C.new(:a<b>);
camelia 1
{a => b}
tonyo yea
jaguart how do I get pairs to be accepted? ie a sig that says no-named args? 02:38
tonyo kind of depends on your use case, are you trying to get a list of pairs? 02:39
jaguart no - just one arg, even if its a pair 02:40
tonyo m: sub a (\x) { dd x; }; a(:hello<world>.Pair) 02:42
camelia :hello("world")
tonyo or you can do this but it's more difficult to grok imo
m: sub a (\x) { dd x; }; a((:hello<world>))
camelia :hello("world")
tonyo or, with the class: 02:43
m: class C {method new (Mu \x) { say x; } };C.new((:a<b>));
camelia a => b
jaguart can I not do it on the Signature side? rather than the caller side?
tonyo this is super ugly and i'm sure there's a better way 02:47
m: multi sub a(*%x where {.keys == 1}) { a(Pair.new(%x.keys[0], %x{%x.keys[0]})); }; multi sub a(Pair:D \x) { dd x; }; a(:a<b>);
camelia :a("b")
jaguart nice - I can do a multi with Pair:D - that works 02:48
jaguart I thought I heard somewhere about ( $x, *% () ) forcing *% to be empty - but cant get that working 02:49
oops - multi seems to give me a problem because my class is a transparent factory :( 02:52
rf So how does a method know the difference between a pair and a named arg, does it take in the argument then see if there is a corresponding named arg? 03:13
jaguart meh: had to `multi method new ( Mu \x = Nil, *%opt ) {` and then code if x == Nil and %opt.elems ==1 03:14
I think that unless you use the extra `()` or Pair.new('x',1) as a caller you can't. 03:29
It seems that the Capture side of the question is pair-greedy - all the unadorned pairs end up in named. 03:30
m: Pair.new("hey","ho").Str.raku.say 03:31
camelia "hey\tho"
jaguart unexpected use of tab?
ugexe thats just how Pairs were made to stringify apparently 03:42
it originated with github.com/rakudo/rakudo/commit/43...661d1b6R12 03:44
m: my %a = a => 1, b => 2; say %a.Str.raku 03:45
camelia "a\t1\nb\t2"
ugexe as such i wouldn't call it unexpected 03:46
jaguart oh that makes sense... I was thinking one-pair, but a hash looks better when it's keys are tabbed
jaguart umm: I inspected a sub and got: `methods : [Capture of returns]` - and spent 10 minutes debugging before discovering that this is not a sentence, but indeed a list of methods on Sub - doh! I thought it was talking to me. 06:09
zep20230124 test 16:08
Abhoerschutz zep20230124: Test succeeded. 16:10
Zephyr test2 16:13
test from the other side
zep20230124 alright, that succeeded too
lizmat succeeded
yup
zep20230124 for some reason the server seemed to have automatically kicked the bridge a bit ago, I'll look into what's causing it 16:14
zep20230124 should be fixed 16:29
tbrowder jaguart: thnx, now i have it mostly working as i expected. but when, as root, i try to uninstall a module i get an error. i’ll have to give more details later, but i’ve seen it before. 16:30
lizmat clickbaits rakudoweekly.blog/2023/01/23/2023-...nk-you-jj/ 17:19
[Coke] tellable6: back 17:23
tellable6 [Coke], I haven't seen back around, did you mean kkkk?
[Coke] ... ww. :)
my windows install is now complaining on 'zef install App::Cal' "Cannot create a Zef::Distribution from non-existant path" 17:31
[Coke] where the path is to a .tar.gz\META6.json 17:37
and the .tar.gz is an empty folder.
ugexe how long is that path? 17:38
[Coke] ugh. removed ~/.zef - now it's complaining that it can't fetch 360.zef.pm/ 17:39
doing a full reinstall of rakudo/zef. 17:40
(from 2022.07)
ugexe those are certainly strange. appveyor shows that zef can install .tar.gz files here -- github.com/ugexe/zef/blob/main/.ap...or.yml#L76 and shows it can recover from deleting the data in ~/.zef here -- github.com/ugexe/zef/blob/9779091b...ml#L91-L92 17:41
[Coke] could be a result of me trying to update to 2022.12, backing out, reinstalling .07 earlier... thought I had wiped the install, but doing again, just to be safe. 17:42
wiped install directory, rebuilt/reinstalled raku; installed zef from updated git clone. run "zef install App::Cal" - searching for missing dependencies, extracting aborted, all mirrors updated, cannot create a zef installation from non-existent path (presumably because the extracts aborted) 17:52
how can I get more details on the aborted extracts?
(it had 3 extracts that were reported as aborted) 17:54
zef install Data::Dump (one of the deps) installs fine 17:55
data::dump is one of the ones that complained that the extract aborted when trying to install App::Cal 17:58
ugexe atm i don't think there is a good way. you could edit these two lines to show the output from the command, and rerun zef via `raku -I. bin/zef install App::Cal` -- github.com/ugexe/zef/blob/9779091b...od#L97-L98
[Coke] Trying to do Text::Tabs, one of the deps. if I run with --verbose it says that fetching and extraction ran ok, but still errors on "cannot create zef::distribution" and if I look at the path, there is again an empty .tar.gz folder with no META6.json (this after again removing ~/.zef) 18:01
ugexe what is the full output with --verbose 18:03
[Coke] if I remove the :bin in the stderr and add "say $_", I see "tar: ..\<...>.tar.gz: cannot open: no such file or directory, error is not recoverable" 18:04
ugexe i wonder if there is a difference in the tar files that work vs dont 18:05
[Coke] have there been any changes to zef recently that would impact how path names are created or interpreted? 18:06
I think Data::Dump complained once and then worked when run directly
ugexe no 18:07
[Coke] gist.github.com/coke/e578a8e6da5c1...b6fc2b27fd 18:08
that includes verbose and the diagnostic tar output 18:09
I am running in git bash on windows, fwiw. (and until recently have had no issues with zef installs) 18:10
~/.zef/tmp has a bunch of <hex>.tar.gz and corresponding <hex>.tar.gz.lock entries. 18:11
didn't check byte for byte, but the "no such file or directory" does seem to have a directory listing there. 18:12
38fc... has a dist folder underneath which has a META6.json 18:13
cd
]
(oops) 18:14
ugexe github.com/ugexe/zef/blob/9779091b...#L162-L167 -- replace the body of that function with just `code();` if you want to rule out the lockfile stuff
[Coke] ... OOF - if I go to a cmd prompt and run zef from there it works.
I've been running raku & zef under git bash for ages, no idea if something changed on my machine recently to break that. 18:15
but if works at the command prompt, I can deal with that for now.
ugexe is `tar --version` different in between those two shells you are using?
maybe one is using a type of `tar` that needs some adjustment 18:16
[Coke] cmd has bsdtar 3.5.2, git bash has gnu tar 1.34 18:17
so, quite possible. But I haven't upgraded git bash... in a year, maybe?
ugexe zef supports both afaik (macos uses bsdtar, and linux usually gnu tar), so maybe something windows specific
[Coke] weird. Thanks for helping me track it down.
(even with things working in CMD, still had to do File::Directory::Tree with --/rea) 18:21
rf I'm having some issues converting a list of lists to a map, does anyone see anything wrong with this? @my-list>>.map({ Map.new(name => @_[0], author => @_[1], href => @_[2], rating => @_[3]) }) where @my-list = [['abc', 'abc', 'abc', 'abc]]; 18:35
List of lists to a list of maps
lizmat m: dd Map.new( foo => 42 )' 18:42
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> dd Map.new( foo => 42 )⏏'
expecting any of:
infix
infix stopper
postfix
statement end
statement…
lizmat m: dd Map.new( foo => 42 )
camelia Map.new
lizmat m: dd Map.new( (foo => 42) )
camelia Map.new((:foo(42)))
lizmat rf ^^
rf Ah, the parens bite me once again, thanks Liz! 18:43
lizmat Map.new would just silently eat the named variable, you need to provide them as a list of Pairs
it's bitten me plenty as well :-(
rf I will gladly take this over the junk I've dealt with in other language, Raku rocks nonetheless 18:44
p6steve m: say 'ok from discord'; 18:45
m: (foo => 42).Map 18:48
rf m: say 'okay from IRC';
camelia okay from IRC
p6steve m: (foo => 42).Map.say
^ just wondering if this a bit nicer 18:49
lol - just wondered if m: works from this side of the bridge 18:50
m: %(foo=>42).say 18:52
rf Is there a way I can construct a without using Map.new and without binding it to a container with the %sigil?
Construct a map* 18:53
something like `(:hello("world"), :eggs("yum")) is Map`
p6steve m: (:hello("world"), :eggs("yum")).Map.WHAT 18:54
rf m: (:hello("world"), :eggs("yum")).Map.WHAT
camelia ( no output )
rf m: (:hello("world"), :eggs("yum")).Map.WHAT.say
camelia (Map)
rf Aha! Thank you!
p6steve Personally I try to use Array and Hash over List and Map ... there is better support for literals and they sit better with the sigils 18:55
tonyo Map.new( (<pairs) ) also does it 18:56
p6steve m: %(:hello("world"), :eggs("yum")).WHAT.say
tonyo m: say Map.new((:a<A>,:b<B>)) 18:56
camelia Map.new((a => A, b => B))
tonyo m: %(:hello("world"), :eggs("yum")).WHAT.say
camelia (Hash)
p6steve m: %(:hello<world>, :eggs<yum>).WHAT.say 19:01
m: %(:hello<world>, :eggs<yum>)<eggs>.say
rf p6steve: I'd prefer for it to be immutable in my case, but I understand what you mean. 19:12
tellable6 rf, I'll pass your message to p6steve
Nemokosch Also apparently neither Map nor List are parametrizable 19:18
p6steve rf - fair enough, with raku you have the choice. For me, I would be thinking Map is not really immutable and since raku is more about clarity than speed then Hash is a bit more natural 19:21
Nemokosch indeed it's not really immutable. I hope one day codesections will just show up with the persistent data type implementation... 19:22
p6steve ValueMap+ (now), true Immutable++ (when it comes) ... in the spirit of raku can do it all ... 19:27
... but a Hash can do everything a Map can and more, so (for me) for smallish programs that need "meat & potatoes" coding why strip back? 19:30
Nemokosch m: %(Map.new(:2foo)).WHAT.say # is this a Map? 19:31
oh right
food for thought? 😛
p6steve tata 19:35
Nemokosch what do you mean? 19:43
tonyo m: %(Map.new(:2foo)).WHAT.say # is this a Map? 19:51
camelia (Map)
Geth ecosystem: 2colours++ created pull request #612:
Time::Duration moved to fez
20:45
[Coke] . 21:30
jaguart tbrowder: I've given up on zef-as-root for the moment, install fails with odd permission issues, uninstall/reinstall rakudo and now running in user-mode. Doesn't bode well for production commissioning. TBH I'm not sure if its zef, the 2022.12 build (see windows issues on github), or quality issues with dists. It's on my to-do 22:32
Nemokosch 2022.12 was kind of a jump into deep water, wouldn't be surprised if some weirdness sneaked in during the many changes 22:39
jaguart I'm hoping next release will fix windows workflow tests on github - otherwise that will become a mental toothache 22:50
Nemokosch I wouldn't keep my hopes high in your place... is it even an analyzed bug or just "used to work before, doesn't work now apparently"? 22:57
jaguart I hoped ugexe would be the one to raise an issue - they seemed to have more of an idea when we --ll-exception'd it 22:59
Nemokosch ugexe probably indeed know more about it than we would but yes, it's kind of a niche 23:02
ugexe jaguart: do you have a windows vm? 23:05
cokebot9000 test 23:13
ugexe github.com/rakudo/rakudo/commit/cc...82a56d8e6d and github.com/rakudo/rakudo/commit/93...455f664079 are the only two things in the 2022.12 release that look related to precomp stuff, so if you (or someone else) had such a VM they could try reverting those commits to see if it improves anything. that would give a better idea of what to 23:14
poke (although those commits are otherwise doing the right thing and we shouldn't expect to revert them to solve this)
tonyo what exactly is the issue? 23:18
or, what is the goal that is raising the issue
ugexe my personal issue is i cant get github actions to finish the CI tests that appveyor finishes 23:19
it seems to be related to precompilation files in one way or another 23:20