🦋 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.
00:00 Doc_Holliwood left
Xliff moritz: Since you were interested before - gist.github.com/Xliff/23d83c2ddcfc...c572caa87d 00:03
00:05 cpan-raku left 00:06 cpan-raku joined, cpan-raku left, cpan-raku joined
stoned75 what was the reason for github.com/rakudo/rakudo/commit/42...bb0bed2fb9 ? 00:10
lizmat stoned75: because, just as Lists, Maps can have containers as values, and are thus potentially mutable, and thus not value objects 00:12
stoned75: see also: github.com/rakudo/rakudo/pull/3331 00:13
stoned75 ok. I see. obvious ! thanks !
ah. and of course Dict is not yet documented :-) 00:17
ah but it's not merged, silly me
00:22 melezhik left
lizmat yeah... it will be a little while still 00:23
00:29 brtastic left 00:48 pecastro left 01:07 guifa2 joined 01:17 stoned75 left 01:43 guifa2 left 01:48 jmchael left
kawaii Hello, I'm trying to use the YAMLish module to turn the contents of this document (github.com/mybb/mybb.com/blob/gh-p...mbers.yml) into a hash, using the `username` attribute as the key but using the `load-yaml` method only ever gives me one large item, any ideas? It strikes me that YAML seems difficult to parse compared to JSON 02:02
02:06 seanrobert joined
Xliff gist.github.com/Xliff/fcf214158ad5...25b9b72dc0 02:15
^^ jnthn sena_kun
kawaii: Looking... one sec. 02:16
kawaii Xliff: thanks, appreciate it :) 02:18
Xliff kawaii: Are you using YAML or YAML::Parse?
kawaii Xliff: github.com/Leont/yamlish
YAMLish
If there's another module I'm happy to try :)
02:21 seanrobert left
Xliff kawaii: OK. What comes out is an array of hash objects 02:22
You will need to further process it if you want it to be a hash,
my $o = load-yaml("test.yml".IO.slurp); my %h = (gather for $o[] { take Pair.new(.<username>, $_); }).Hash 02:24
kawaii Xliff: ahhh I see my mistake, I was doing load-yaml directly into a hash object 02:26
thank you so much, this is perfect
Xliff You're welcome!
tony-o: You still around? 02:32
Is there a way to check if a dynamic variable exists? 02:35
02:35 guifa2 joined 02:42 mowcat left
sortiz m: say defined($*VM), defined($*FooBar) # Xliff 02:42
camelia TrueFalse
Xliff sortiz++ 02:43
ThanksMuch
sortiz YW
guifa2 Note that that won't tell you if it exists 03:07
only that it is undefined
my $*a = Str; say defined $*a
evalable6 False
03:08 asymptotically left, asymptotically joined 03:14 JRaspass left
guifa2 Xliff: you'll actually want to use '$*foo' (elem) CALLERS::.keys 03:15
03:17 berber44 joined
guifa2 (there may be another way by accessing the stash — I think vrurg was working on that, but I feel like this is the most idiomatic way to get it 03:17
vrurg m: say $*NOVAR.raku; 03:19
camelia Failure.new(exception => X::Dynamic::NotFound.new(name => "\$*NOVAR"), backtrace => Backtrace.new)
vrurg m: my $*ADYNAMIC = pi; say DYNAMIC::<ADYNAMIC>:exists; 03:20
camelia False
vrurg Hm...
m: my $*ADYNAMIC = pi; say DYNAMIC::<$*ADYNAMIC>:exists; 03:22
camelia True
guifa2 ah duh, I always forget about that adverb
Although I think CALLER could be better than DYNAMIC 03:24
If you declare the variable in the same scope, but later somehow, it seems to still give you true 03:25
actually no, CALLERS still gives true, at least in REPL 03:26
03:26 Xliff left
vrurg guifa2: callers would give you not only dynamics, if memory serves me right. 03:28
m: my $foo = 42; sub foo { say CALLERS::<$foo>; }; foo;
camelia 42
vrurg m: my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo;
camelia 42
vrurg 6e: my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo; 03:29
m: use v6.e.PREVIEW; my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo;
camelia Don't know setting RESTRICTED
at gen/moar/ModuleLoader.nqp:249 (/home/camelia/rakudo-m-inst-1/share/perl6/lib/Perl6/ModuleLoader.moarvm:previous_setting_name)
from gen/moar/ModuleLoader.nqp:254 (/home/camelia/rakudo-m-inst-1/share/perl6/lib/…
vrurg Ok, 6.c/6.d do have some problems which are going to be there for backward compat. But 6.e must be different. 03:32
Sorry, my bad. The difference between DYNAMIC and CALLERS is the former also lookups in the current scope whereas CALLERS starts with the caller scope. 03:35
guifa2 vrurg: yeah, that's why I was thinking CALLERS might be better because UNIT includes post-declared variables 03:41
and I can imagine in a recursive routine, someone doing if CALLERS::<$*foo>:exists { do one thing } else { my $*foo = 5; callsame } or something like that 03:42
guifa2 actually did basically exactly that with one of his modules
I guess in that case the else block is separate, but the declaration could happen separately somewhere in the same scope 03:43
03:53 berber44 left 04:53 nativecallable6 left, benchable6 left, unicodable6 left, committable6 left, greppable6 left, linkable6 left, notable6 left, bloatable6 left, releasable6 left, statisfiable6 left, evalable6 left, tellable6 left, bisectable6 left, quotable6 left, squashable6 left, shareable6 left, coverable6 left, sourceable6 left 04:54 benchable6 joined, coverable6 joined, greppable6 joined, sourceable6 joined, linkable6 joined, evalable6 joined 04:55 shareable6 joined, bisectable6 joined, squashable6 joined, nativecallable6 joined, unicodable6 joined, quotable6 joined 04:56 bloatable6 joined, statisfiable6 joined, notable6 joined, tellable6 joined 04:57 committable6 joined, releasable6 joined 05:27 seanrobert joined 05:36 seanrobert left 05:43 rindolf joined 05:52 sortiz left 06:10 k-man joined 06:32 guifa2 left 06:33 parabolize left 06:49 brtastic joined
notandinus when should i break a script into modules? 06:53
it's ~162 lines 06:54
moon-child notandinus: when it becomes difficult to maintain in unified form
notandinus i see, so i'll just keep it as single script 06:58
no need for zef right if it's a single script?
07:04 jmerelo joined
notandinus what does * before @ signify? 07:11
sub MAIN(*@test)
^^ in this?
jmerelo notandinus: it makes it a slurpy docs.raku.org/type/Signature#Slurpy_parameters 07:23
07:24 frost-lab joined 07:30 sjm_uk joined 07:34 wamba joined, sena_kun joined 07:35 Sgeo left
notandinus i see, thanks 07:37
07:47 ufobat joined 07:54 aborazmeh joined, aborazmeh left, aborazmeh joined, domidumont joined 07:58 notagoodidea joined 07:59 brtastic left 08:03 wamba left 08:11 stoned75 joined 08:31 MasterDuke joined 08:32 abraxxa1 joined
notagoodidea I have this messy line that I am sure there is a better way to code: 08:33
`.grep(/TODO/) ?? s/TODO/DONE/ !! s/DONE/TODO/ if .grep /$todo/ for @todos; ` 08:34
@todos is a array of string with the format "(TODO|DONE) XXXX" and $todo is a string
any suggestion to for in-place modification and get rid of the `.grep ?? !!` pattern ? 08:36
08:37 abraxxa1 left 08:38 abraxxa1 joined
jmerelo notagoodidea: well, there's always a loop... You can use rw loop variables. 08:51
m: constant $VER = 3; class Foo:ver{$VER} {};
camelia Block object coerced to string (please use .gist or .raku to do that)
jmerelo Hum
m: constant $VER = v3; class Foo:ver{$VER} {}; 08:53
camelia Block object coerced to string (please use .gist or .raku to do that)
notagoodidea jmerelo: something like : `for @todos -> $t is rw { * }`?
jmerelo notagoodidea: right
m: constant VER = v3; class Foo:ver{VER} {}; 08:54
camelia Block object coerced to string (please use .gist or .raku to do that)
jmerelo m: constant VER = v3; class Foo:ver{VER} {}; say Foo.^ver
camelia Block object coerced to string (please use .gist or .raku to do that)
v
jmerelo m: constant VER = 3; class Foo:ver{VER} {}; say Foo.^ver
camelia Block object coerced to string (please use .gist or .raku to do that)
v
jmerelo m: constant auth = "Þor"; class Foo:auth{auth} {}; say Foo.^auth 08:55
camelia -> ;; $_? is raw = OUTER::<$_> { #`(Block|68336832) ... }
notagoodidea my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { s/foo/bar/ }; say @foo; 08:56
m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { s/foo/bar/ }; say @foo;
camelia Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
[foo 1 bar 2]
in block at <tmp> line 1
Use of uninitialized value of type Any in string con…
jmerelo m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f ~~ s/foo/bar/ }; say @foo; 08:57
camelia [bar 1 bar 2]
jmerelo notagoodidea: ^^^ remember s by default acts on the context variable.
08:59 ufobat left
notagoodidea right! Maybe is it clear to do `{ $f .= subst() }` in this case. 08:59
09:00 ufobat joined
notagoodidea m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/foo/, "bar") }; say @foo; 09:00
camelia [bar 1 bar 2]
09:01 Doc_Holliwood joined
notandinus Str $action, #= action to perform (ex. backup, rotate)) 09:01
*@profiles, #= profiles to perform the action on
# Str $profile,
Bool :v(:$verbose), #= increase verbosity)
Bool :$version, #= print version
);
oof, sorry for the paste, i was trying to paste the link 09:02
ix.io/2L8U
^ can i make --help display the sub-actions?
09:02 ufobat left
MasterDuke i think you can define your own USAGE 09:03
notagoodidea notandinus: check bduggan.github.io/meta-perl6-cli/#31
MasterDuke docs.raku.org/language/create-cli#...ntry-USAGE
09:05 pecastro joined
notagoodidea m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/1/, "bar") if .grep(/foo/) }; say @foo; 09:06
camelia Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
[foo 1 bar 2]
in block at <tmp> line 1
Use of uninitialized value of type Any in string con…
notagoodidea m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/1/, "bar") if $f.grep(/foo/) }; say @foo;
camelia [foo bar bar 2]
notagoodidea m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/bar/, "lala") if $f.grep(/foo/) }; say @foo;
camelia [foo 1 bar 2]
09:08 ufobat joined
MasterDuke m: my @foo = ["foo 1", "bar 2"]; for @foo.grep("foo") -> -> $f is rw { $f .= subst(/bar/, "lala") }; say @foo 09:09
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3 1", "bar 2"]; for @foo.grep("foo") -> -7⏏5> $f is rw { $f .= subst(/bar/, "lala")
MasterDuke m: my @foo = ["foo 1", "bar 2"]; for @foo.grep("foo") -> $f is rw { $f .= subst(/bar/, "lala") }; say @foo
camelia [foo 1 bar 2]
notagoodidea han :D
MasterDuke your `$f.grep` is trying to do a list operation on a string 09:10
you probably want `$f.contains` 09:11
09:11 JRaspass joined
notagoodidea I certainly want it now :) 09:11
thanks
MasterDuke np
notandinus MasterDuke: notagoodidea: thanks, 09:16
how do i get "where" part for this param? &MAIN.signature.params[0] 09:20
Str $action where * ∈ <backup rotate>
^ it's defined like this, .params[0] is $action, i need <backup rotate> part from it 09:21
so that i don't have to define it twice, i'm going to define my own USAGE
jmerelo notandinus: not sure it's accessible. It might be, though...
notandinus when i print &MAIN.signature.params[0], it does say 09:22
MasterDuke create a subset first and use it in both?
notandinus Str $action where { ... }
MasterDuke: i see, i'll check that
jmerelo notandinus: um, that would be a Parameter type, and it does have a .constraints method. docs.raku.org/type/Parameter Give it a try. It might be .signature.params[0].constraints 09:23
09:24 aluaces joined
notandinus jmerelo: all(WhateverCode.new) 09:25
MasterDuke i think it comes from github.com/rakudo/rakudo/blob/mast...n.pm6#L208
notandinus that returns ^
i'm trying the subset thing
notagoodidea notandinus: from there bduggan.github.io/meta-perl6-cli/#38 and the fact that `MAIN("alice")` is behind the hood `MAIN(Str $foo where {$foo eqv "alice"}` 09:26
jmerelo notandinus: right, it's not terribly helpful... Mainly you can't extract individual elements out of a Junction, I think. Introspection can only take you so far... 09:27
notandinus notagoodidea: ah i forgot that, thanks 09:28
yeah it's a junction thingy 09:29
i've defined a subset like this: subset Action of Str where * ∈ <backup rotate>;
notagoodidea Don't you will have the same issue to access the value of the Junction there ? 09:30
notandinus oh wait, i could just define an array @actions now and put <backup rotate> in it,
notagoodidea: yeah not a good idea ;)
notagoodidea notandinus: That's what I have done when I played with it.
`my @sub = <foo bar> ; ... MAIN(Str $sub where { * eqv any @sub });` 09:31
notandinus wait then i don't have to bother with subset
notagoodidea But maybe an enum is better there ?
notandinus yeah i'lll just do where * ∈ @actions
notagoodidea: i don't know what an enum is , i'll check it out 09:32
notagoodidea I was just looking at it yesterday so, pinch of salt because I am not sure to have a full grasp of the enums in Raku
notandinus hmmi also need to have description for each action, i'll make it a hash for now 09:35
hmm the enum thing is working fine 09:41
using a subset will work the same way right?
09:41 Altai-man joined
notandinus or even a constant @array 09:42
09:44 sena_kun left
notagoodidea notandinus: for the MAIN part yes. With a subset you will call it `MAIN(Action $str, ..)` 09:46
I just don't know if it convinient for the USAGE after, or just harcode it somewhere. 09:47
09:47 aborazmeh left
notandinus notagoodidea: enum looks good, i made it an enum 09:48
enum Actions ( backup => "make a backup) 09:49
^ this way i can just use the hash directly to print usage
and restrict it too
notagoodidea Is there a profiler for raku? 10:01
notandinus yeah, just run --profile 10:02
10:04 brtastic joined
notandinus ok so i need a --version flag 10:15
$action needs to be passed all the time except when --version is passed, how do i define this? 10:16
i can make a multi MAIN, is that the best way?
notagoodidea maybe you will have to make $action optional, I am not sure how the multi sub dispatch with positional parameters & flags? 10:24
notandinus: I remember, multi sub yes but you will need to have a general case MAIN to call USAGE when to params are passed or it will dispatch on the sub with the version flag (or the last flag). 10:33
or not. 10:34
notandinus notagoodidea: i've defined it like: multi sub (Bool :$version) {} multi sub (Action $action,... ) {} 10:36
and it seems to work fine
i added is-hidden-from-USAGE in first multi and added a :$version to second multi too so that it comes up in usage
when --version is passed, first multi gets called, 2nd one is all other cases. 10:37
notagoodidea mm, notandinus this minimal version always dispatch on :$version sub (outputing "ALPHA") when called without parameters : pastebin.com/S0N4QzgF 10:45
but I don't know why. 10:47
kawaii Does Raku have some built-in way to check the age of a variable or when it was last written to/updated? 10:50
MasterDuke dispatching with named variables can be a little tricky, recommend reading docs.raku.org/language/functions#i...i-dispatch 10:51
notandinus notagoodidea: hmm yeah , no t sure why
MasterDuke kawaii: no, but istr someone wrote a module to do something similar
samebchase- kawaii: no, you'll need to define your own object which keeps tracks of updates or use a module as MasterDuke suggested 10:52
kawaii Okie, thanks :)
notandinus mine is : paste.debian.net/hidden/59ff407b/
and it dispatches on second multi in all cases except when --version is passed
11:04 linkable6 left, evalable6 left 11:06 evalable6 joined, linkable6 joined 11:10 Black_Ribbon left
notagoodidea notandinus: Does yours call USAGE on empty parameters ? 11:12
11:13 moony joined
notagoodidea MasterDuke: For what I see, because named argument prevails on arity, the dispatch will always go to the named argument. 11:14
So for MAIN, it is a bit weird because it will output the first flag it will dispatch against. 11:18
11:23 sjm_uk left
notagoodidea mm, it is not that weird in fact if one want to reproduce a command like `ls` but to mimic `git` and call the help when no parameters provided, we must use a catch-all flag at the beginning of the multi-dispatch to call USAGE. 11:24
notandinus notagoodidea: yeah it calls USAGE on empty params 11:33
notagoodidea: oh wait 11:36
it doesnt
i dunno why i was saying it does, so i'll have to add an empty multi MAIN? 11:37
11:45 asymptotically left
notagoodidea notandinus: That will not work like in my example. If I understand multi dispatch correctly, named argument seems to prevails. A solution seems to be to put a named argument on top of all and made him call USAGE like 'multi sub MAIN(Bool :$help-implied) { say $*USAGE }` before the multi calling version for you. 11:48
11:50 asymptotically joined, jmchael joined
notandinus notagoodidea: i see, thanks. that works fine, one could also do `$version ?? say "Leo v0.6.0" !! USAGE();` right? 11:51
11:56 olve joined 11:58 wamba joined
notagoodidea notandinus: than works yep. 12:02
SmokeMachine m: sub toggle(@a, $name) { @a.grep(*.contains: $name).map: { .subst-mutate: /^ (DONE|TODO)/, { %(DONE => "TODO", TODO => "DONE"){ $_ } } } }; my @a = "TODO xxx", "DONE yyy"; say @a; toggle @a, "xxx"; say @a; toggle @a, "yyy"; say @a 12:09
camelia [TODO xxx DONE yyy]
[DONE xxx DONE yyy]
[DONE xxx TODO yyy]
SmokeMachine notagoodidea: ^^ 12:10
12:12 Doc_Holliwood left
notagoodidea Oh you can provide Hash to subst! 12:12
SmokeMachine on that case, that's a block... 12:13
notagoodidea There is a warning on subst-mutate no?
SmokeMachine not that I'm aware of..
notagoodidea docs.raku.org/routine/subst-mutate > NOTE: .subst-mutate is deprecated in the 6.d version, and will be removed in future ones. You can use subst with .= method call assignment operator or s/// substitution operator instead. 12:14
SmokeMachine m: say "blablelbibloblu".subst: /a|e|I|o|u/, *.uc
camelia blAblelbibloblu
SmokeMachine m: say "blablelbibloblu".subst: :g/a|e|I|o|u/, *.uc
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix , instead.
at <tmp>:1
------> 3 "blablelbibloblu".subst: :g/a|e|I|o|u/,7⏏5 *.uc
SmokeMachine m: say "blablelbibloblu".subst: :g, /a|e|I|o|u/, *.uc 12:15
camelia blAblElbiblOblU
SmokeMachine m: sub toggle(@a, $name) { @a.grep(*.contains: $name).map: <-> $a { $a .= subst: /^ (DONE|TODO)/, { %(DONE => "TODO", TODO => "DONE"){ $_ } } } }; my @a = "TODO xxx", "DONE yyy"; say @a; toggle @a, "xxx"; say @a; toggle @a, "yyy"; say @a
camelia [TODO xxx DONE yyy]
[DONE xxx DONE yyy]
[DONE xxx TODO yyy]
SmokeMachine notagoodidea: without substantiation-mutate: ^^ 12:16
notagoodidea ok, I got how the block works. 12:17
12:17 olve_ joined
SmokeMachine (sorry, subst-mutate) 12:18
notagoodidea And i forgot <-> instead of `is rw`.
The surface of Raku feels endless sometimes
12:19 olve left
Altreus hello, what's this <-> 12:19
notagoodidea <-> mark the parameters of the block as rw. 12:20
Altreus oh, the doc search actually understands punctuation
that's a pleasant surprise
that's a super helpful thing to know! 12:21
12:31 MasterDuke left 13:15 guifa2 joined 13:22 aborazmeh joined, aborazmeh left, aborazmeh joined 13:25 MasterDuke joined 13:34 jmerelo left 13:42 sena_kun joined 13:43 Altai-man left 13:45 olve_ left 13:53 xelxebar left 13:57 wamba left 14:01 abraxxa1 left 14:05 frost-lab left 14:08 abraxxa1 joined 14:09 wamba joined 14:13 mowcat joined 14:18 sno left 14:21 sno joined 14:25 abraxxa1 left 14:26 aborazmeh left, xelxebar joined 14:27 mowcat left 14:31 abraxxa1 joined 14:35 cpan-raku left 14:36 abraxxa1 left 14:37 domidumont1 joined 14:40 domidumont left 14:44 rindolf left 14:45 cpan-raku joined, cpan-raku left, cpan-raku joined 14:54 Sgeo joined 14:57 Tirifto joined 14:59 abraxxa1 joined 15:07 rindolf joined
Tirifto Hello! Is my understanding right that re-dispatching a call to .new to a parent class via ‘callsame’ will result in the class’ own BUILD/TWEAK/bless (sub)methods not being called? 15:15
15:16 aborazmeh joined, aborazmeh left, aborazmeh joined
guifa2 They should be called because callsame is still taking place in the original new scope 15:23
Tirifto Ah, looks like I’m missing something else then. Thank you, guifa2! 15:25
15:25 tech_hutch joined
guifa2 Well, I just tested it, but I do kind of agree — something does feel off 15:25
tech_hutch Hello 15:27
🦋
guifa2 greetings tech_hutch! 15:28
Tirifto Howdy! 🦆️
[Coke] wonders if he can change his nick to 🥤 15:30
15:31 Doc_Holliwood joined
tech_hutch So I was trying out the REPL, and things seemed a little odd 15:31
tbrowder yo, all, anyone else having trouble with github workflow tests?
perry [Coke] you could always do U+1F964
tbrowder for their modules?
tech_hutch It says `Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.12.` Is that just my terminal encoding being set wrong?
perry tech_hutch: ha. probably. 15:32
tech_hutch Like, is it trying to say Raku in Japanese or something? lol
perry tech_hutch: here's what it looks like for me: i.imghurr.com/e/MDUrObsPHx.png
tbrowder i'm getting "operation cancelled" when zef is searching for dependencies 15:33
tech_hutch Ohhh okay. So it's using some odd Unicode chars
perry It's UTF-8. Mathematical bold letters.
tech_hutch `~` is the string concatenation operator, right? and so `~=` would concatenate and reassign? 15:35
I'm getting some strange results. Sometimes when I do, e.g., `my $thing = "hi"` `$thing ~= " there"`, subsequently doing `$thing` prints "hi there there", "hi there there there", etc. 15:37
Is this just a repl bug?
perry tech_hutch: not sure what you mean. This is what I see: i.imghurr.com/e/mZMDMTPDbl.png 15:38
15:39 parabolize joined
tech_hutch Sometimes that happens for me (which is what I'd expect), but other times I get the weird behavior I just described 15:39
I'm new to IRC, can I upload images here?
perry I think webchat is through kiwi, so I think so 15:40
Tirifto tech_hutch: Ha, I just got the same behaviour as you! (Or similar, at least.)
15:40 perryprog-pg joined, perryprog-pg is now known as perryprog-dg
tech_hutch I don't see any way to upload 15:40
15:40 perryprog-dg left
perry Huh. I don't either. 15:41
tech_hutch Here's an image I uploaded to Discord yesterday (I think you can see it without an account): media.discordapp.net/attachments/2...nknown.png
perry Huh. That's interesting. 15:42
Tirifto tech_hutch, perry: Here’s the output of mine: zerobin.net/?dc0bb01b57eb7c7d#DQYg...PyUc3oI8Q=
perry Doing the exact same thing Tirifto, I get different output 15:43
notagoodidea it doe not incremet "there" on mine.
perry notagoodidea: that's cause you're cool like me 15:44
Tirifto, is this also in Powershell?
notagoodidea <3
tech_hutch It's not doing it for me now
Tirifto :P
notagoodidea Here it's rakudo 2020.02 / 6.d on Fedora with fish.
tech_hutch The cool kids don't experience repl bugs 😎
perry notagoodidea, same here but macOS 15:45
and also Fish :)
tech_hutch Mine is PowerShell through Windows Terminal
notagoodidea perry: indeed like you :D
perry tech_hutch, can you reproduce it with either 1) the text Tirifto sent or 2) in a different terminal emulator?
Tirifto I’m running Rakudo 2020.12 in Bash on Parabola GNU/Linux-libre (derived from Archlinux), installed with the help of AUR (a community package repository).
perry This bug has nerd-sniped me I think 15:46
Oh wow that's weird
Tirifto Oh wait.
perry Oh my Rakudo might be out of date then. Just realized I'm on 0.10. 15:47
2020.10*
Tirifto I may actually be running a non-release version.
perry gasps
Tirifto I do recall installing 2020.12 and finding it oddly slow to start, so I tried installing the version from master, and I might be running that now… but that said, 2020.12 did feel kind of weird right from the start. 15:48
tech_hutch perry yes, exactly the same output for me 15:49
perry waaaaaat
tech_hutch cdn.discordapp.com/attachments/250...nknown.png
Tirifto tech_hutch: Did you install the ordinary Rakudo 2020.12 release version? 15:50
MasterDuke the repl has always been a bit odd and had bugs unique to itself. lizmat++ made some changes recently, so there might be new behavior 15:53
15:53 abraxxa1 left 15:54 [Coke] joined, [Coke] left, [Coke] joined
lizmat yes, the REPL has new quirks :-) 15:55
tech_hutch Tirifto yeah, from here rakudo.org/downloads
perry "surprise features"
[Coke] oof, that was weird. on mac. jostled something, got an alert that the external drive with everyone's home dirs on it needs to be shut down before you unplug it. it was still connected, but my Dock preferences were all reset. weird. 15:56
tech_hutch I just worry bugs like this would confuse a newcomer (like me) even more 15:57
Tirifto I can confirm that ‘hi there’ works as expected in a script.
tech_hutch That's good, at least
MasterDuke i just checked and that odd behavior doesn't happen on 2020.08 15:58
tech_hutch Also, you know what would be cool? A place online where you can try out Raku without downloading anything, like a lot of other languages have
(unless there is one and I missed it)
15:59 guifa2 left
[Coke] there is. one sec. 15:59
tyil glot.io has Raku support, no?
MasterDuke m: say "hi"
camelia hi
15:59 guifa2 joined
tyil tech_hutch: glot.io/new/raku 15:59
MasterDuke also run.tio (or tio.run, can never remember the order)
tyil tio.run iirc
don't think .tio is a valid tld (yet) 16:00
tech_hutch ah cool. the site should link there
[Coke] (one sec until others fill in the URL, thanks. :) 16:01
Tirifto p6: my $thing = “hi”; $thing ~= “ there”; say $thing; say $thing; $thing ~= “ there”; say $thing; say $thing;
camelia hi there
hi there
hi there there
hi there there
Tirifto The evalbot is safe. :-)
MasterDuke those are linked from raku.org/resources/
guifa2 Is there any way to substr a str and get a str back (that is, avoiding boxing)? 16:02
tech_hutch MasterDuke ah ok. Still would be nice to link it more prominently. E.g., Go has one embedded right in the homepage 16:03
MasterDuke i think there is a doc issue about similar ideas (e.g., make the examples in the docs runnable/editable) 16:04
github.com/Raku/doc/issues/1866 16:07
El_Che tio is uncle in spanish 16:08
notagoodidea m: say "foo bar".WHAT; say "foo bar".subst(/foo", "baz").WHAT; 16:10
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1)
at <tmp>:1
------> 3 say "foo bar".subst(/foo", "baz").WHAT;7⏏5<EOL>
expecting …
notagoodidea m: say "foo bar".WHAT; say "foo bar".subst(/foo/, "baz").WHAT;
camelia (Str)
(Str)
MasterDuke guifa2: maybe if you nqp ops directly 16:11
*use 16:12
guifa2 MasterDuke: I was afraid that'd be the answer lol. Trying to avoid nqp
MasterDuke fwiw, Strs and strs are pretty similar, not like int and Int 16:13
why don't you want the boxing?
16:14 aborazmeh left, Doc_Holliwood left
[Coke] Is there interest in having a sort algorithm like tcl's [lsort -dictionary]? ("in -dictionary mode, bigBoy sorts between bigbang and bigboy, and x10y sorts between x9y and x11y.") 16:15
could do it as a sub for folks to pass to .sort... 16:16
tech_hutch oh, so this language has autoboxing?
MasterDuke tech_hutch: yep 16:18
16:18 mowcat joined
guifa2 Masterduke: I know the boxing and unboxing are extra ops that I'd like to avoid — I'm doing an sprintf-like operation, and I'm playing around with different things to keep it is nimble as possible. Using native ints can be a massive speed up, so I was hoping I might get similar out of strs 16:18
MasterDuke m: my int $a = 4; say $a.WHAT
camelia (Int)
MasterDuke ^^^ the int variable was autoboxed to an Int when the method was called 16:19
guifa2: i think it'd be a tiny difference
[Coke] m: my str $a = "eek"; say $a 16:20
camelia eek
guifa2 I think I can pull off the algorithm to avoid substrs, but at the cost of more math, so I'll need to test the trade off perf wise 16:23
guifa2 . o O ( formatting numbers is a lot more complicated than one might think! )
Tirifto On that note, how do you tell whether or not it’s been autoboxed? 16:24
guifa2 m: my Str $a = 'a'; my str $b = 'a'; say $a.VAR.WHAT; say $b.VAR.WHAT 16:25
camelia (Scalar)
(StrLexRef)
Tirifto Oh, nice! 16:26
16:27 aluaces left
tech_hutch do functions only take the boxed versions? 16:29
guifa2 They can take unboxed, but they have to declare them, and they can't distinguish between different types
so sub foo (int64 $foo) { … } will take an int64, int32, int16, etc 16:30
You have to be very conscientious when working with natives to avoid getting them boxed (basically, you have to strongly type your code that uses them) 16:32
MasterDuke generally you're not supposed to care
tyil >You have to be very conscientious when working with natives to avoid getting them boxed 16:33
that's a good sentence when taken out of context
16:34 aluaces joined
tadzik :o 16:34
guifa2 Yeah, what MasterDuke said is very true. The idea of Raku is for the average person to not even think of the native/closer-to-metal-y stuff 16:35
I would never write a normal script using it, but there's also a tradition of developers (core and modules) torturing themselves to benefit the end-user/programmer, so for those situations, it cna make sense to work harder to eek out certain benefits 16:36
tech_hutch Hm okay 16:38
@ty
(whoops) 16:39
tyil I thought the same thing haha
"so sub foo (int64 $foo) { … } will take an int64, int32, int16, etc" guifa2 oh, so the smaller int types subclass the bigger ones? 16:41
16:41 cpan-raku left, vike joined
Tirifto If I want something to happen every time a class is instantiated (no matter how), would putting it in BUILD/TWEAK/bless be the way to go? (It seems like those should be inherent to the instantiation mechanism, or at least close to it.) 16:43
MasterDuke no, they're not subclasses. fwiw, right now rakudo has some limitations/bugs around how the sized natives are handled (also signed vs unsigned natives) 16:44
i'd recommend TWEAK, but yeah, you could use almost any of those. TIMTOWTDI 16:47
Tirifto In that case, am I missing something in expecting this to say ‘Hello!’? 16:49
p6: class Binode is IO::Path { submethod TWEAK () {say ‘Hello!’} }; Binode.new(‘/usr/bin/raku’);
camelia ( no output )
notagoodidea Every time, I read TIMTOWTDI as Tim tows Teddy.
MasterDuke m: class F { submethod TWEAK() { say "F: " ~ self.^name; }; }; my $b = F.new; my $c = F.new; class G is F { submethod TWEAK() { say "G: " ~ self.^name }; }; my $d = G.new 16:54
camelia F: F
F: F
F: G
G: G
16:54 cpan-raku joined, cpan-raku left, cpan-raku joined 16:59 jmerelo joined, thundergnat68 joined
MasterDuke m: class F { submethod TWEAK() { say "F: " ~ self.^name; }; method new($a) { say "a: $a"; }; }; my $b = F.new("f1"); my $c = F.new("f2"); class G is F { submethod TWEAK() { say "G: " ~ self.^name }; }; my $d = G.new("g1"); 16:59
camelia a: f1
a: f2
a: g1
MasterDuke looks like i was wrong. if you define your own new() then TWEAK() isn't called
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 ? 17:00
17:00 thundergnat68 left
[Coke] thundergnat++ 17:01
Tirifto MasterDuke: Indeed. If short-term memory serves well, TWEAK is called by Mu’s ‘bless’ method, which I assumed is how just about all the classes get instantiated. But since IO::Path’s new method doesn’t seem to result in TWEAK being called, it looks like it manages to instantiate the class without calling the default ‘bless’ at some point. Does that sound plausible? 17:08
MasterDuke yeah, it's just calling `nqp::create(self)` 17:09
Tirifto Ah, thanks for checking! 17:11
I guess that leaves me no way of tying specific behaviour to instantiation, unless I alter the compiler? :P 17:13
MasterDuke m: class Binode is IO::Path { multi method new($a) {say ‘Hello! $a’} }; Binode.new("b"); 17:15
camelia Hello! $a
17:15 v_m_v joined
MasterDuke but honestly you need someone like timotimo, lizmat, vrurg, etc who know this stuff better 17:16
17:18 MilkmanDan joined
Tirifto MasterDuke: Thank you. 17:19
MasterDuke np
Tirifto I don’t actually I<need> to do this, but I thought it would be elegant to make it happen automatically. 17:21
Just to leave some context: Using ‘new’ doesn’t achieve the same result for me, since IO::Path seems to get instantiated some other ways, too. For example, I’ve used the File::Find module, which gave me a list of IO::Path subclasses without ever calling ‘new’. (It seems to use ‘dir’, so ‘dir’ in turn doesn’t seem to use ‘new’.) 17:25
jmerelo Tirifto: new is almost never used, most notably so in a class hierarchy. What is _always_ called is BUILD, which is a submethod: docs.raku.org/language/classtut#in...ntry-BUILD 17:26
Tirifto jmerelo: Even when the class is instantiated with ‘nqp::create’, rather than ‘bless’? 17:28
jmerelo Tirifto: OK, let me rephrase what I said above. New is generated automatically with a signature that includes all public attributes, so every class has got a "new". That generated new calls bless, which in turn calls BUILD. If nqp::create is called, probably that sequence is skipped 17:31
tony-o JJAtria[m]: just doing some debugging on the `parse` script for sql and then it should be OK for a merge on that branch 17:34
or, at least, okay for more in depth review
17:36 tech_hutch left
Tirifto jmerelo: Alright, thank you for elaborating. I think I get how approximately it goes. It’s just that I was originally wondering if instantiation would always, without fail, follow a certain adjustable procedure (such as the one handled by ‘bless’). But it seems like that’s not the case, so I’ll just have to not rely on it. :-) 17:39
17:41 Altai-man joined 17:44 sena_kun left, guifa joined 17:45 squashable6 left 17:48 squashable6 joined 17:58 patrickb joined 18:12 tech_hutch joined 18:22 clarjon1 joined 18:28 JRaspass left
tony-o Tirifto: what are you trying to do? 18:34
18:42 tech_hutch left 18:46 aluaces left
patrickb ping rba 18:49
tellable6 2021-01-06T16:29:41Z #raku <tony-o> patrickb merged the config stuff into fez
patrickb tony-o: Did you notice my comment wrt XDG here? github.com/tony-o/raku-fez/pull/4#...r549493435 18:50
18:57 aluaces joined
tony-o i did 18:57
my thoughts concerning that were mostly centered around allowing users to muck around with $HOME 18:58
i also couldn't find the source for that to figure out what it's doing, i did find something that looked like it was created via macro 19:05
19:07 notagoodidea left 19:09 sortiz joined 19:15 domidumont1 left
Tirifto tony-o: I have a program where I’m trying to keep track of files and directories, and keep some data associated with them. To that end, I made a sub-class of IO::Path, which adds a hash attribute to store the associated data. (So far so good.) 19:19
A feature of IO::Path which is handy for me is the ability to get a path to the parent, or make a path to a child. However, that always gives you a new path, and therefore also a new object of my subclass. What I would like to do is basically to have a single permanent object per path, so that if you call ‘parent’ for an object of my subclass, and you have already made an object for the parent before, it gives you that object (which hol 19:23
ds the associated data you wouldn’t get in a new object).
The way I’ve been trying to do this is keeping a hash of all the objects indexed by their stringified paths in the class, but adding the objects to that hash has proved to be a problem, as there doesn’t seem to be a way to make sure that happens whenever an object is created. 19:25
patrickb tony-o: I believe this is it: cgit.freedesktop.org/xdg/xdg-user-...g-user-dir 19:26
19:27 tech_hutch joined
tbrowder FYI, workflow job on github was failing apparently because the windows run in the run matrix was failing an killing the other jobs for ubuntu and mac. commenting out the windows run enabled a green tag. 19:29
patrickb tony-o: I have no really strong emotions wrt XDG. Just wanted to make sure my intentions were understood. 19:31
tony-o patrickb: understood. i really appreciate the MR and most of it is now in master : ) 19:32
guifa Tirifto: I would override the parent method in your subclass, and find a way to pass in the data accordingly
honestly, you might be better served with a mixin than a subclass
tony-o ^ 19:33
guifa role MutableIOWithData { has $.data; method parent { my $foo = self.parent but MutableIOData; $foo.data = self.data; $foo } } 19:34
There are some shortcuts in code syntaax for doing that, but I think what I put is a bit more explanatory 19:35
Tirifto Overriding is what I’ve been doing. I just ran into some cases where creating a new instance of this subclass wouldn’t add it to the hash, and thought making it work globally would be more elegant than defining a set of methods one has to call when they want to get an object of this kind. 19:36
I think I’m going to try just keeping a hash of the associated data structures in the class, getting rid of the attribute and making the ex-accessor link to the hash instead. 19:39
19:39 Doc_Holliwood joined
Tirifto Thank you for the mixin advice though, guifa and tony-o; I’ll look into them for sure, to get a better idea! 19:40
tony-o is your class a singleton ?
19:41 jmerelo left
Tirifto Not really; I need to have many paths (so many objects), but a single place to keep track of them. Until recently I was just doing that in a hash variable, but having to access that directly looked kind of messy, so I thought I’d hide it away. 19:43
guifa mind posting your code to a gist somewhere? We can probably get you some better advice that way 19:44
guifa wrote a module that modifies a core class and ensures the modifications propogate forever 19:45
Tirifto guifa: Sure! Let me just try to apply the fix real quick; it might make more sense if it works. :P 19:48
tony-o using a factory and memoizing based on a path seems like another option
19:59 v_m_v left 20:00 v_m_v joined
Tirifto guifa: It’s a work in progress and it still doesn’t work, but hope it helps. ^ ^’ zerobin.net/?d5de3206b294ab75#9oy8...uL+45ells= 20:07
guifa: Ah, and here’s a MarkDown version generated by Pod::Weave, if you prefer: zerobin.net/?d6dfaad3393e74a7#EjUf...EZ4ZUq8og= 20:11
guifa Okay, I see what you’re doing 20:17
Tirifto The prgram (whose intended use is generating simple websites with the help of sub-programs; hence the EVAL) should look at a tree of nodes (files/directories), process the nodes in some way, and output a different tree of nodes derived from that one. The input tree may contain files with a special extension, which contain metadata about other files (instructions on how the program should handle them).
For the record, the problem which seems to stop the current code from working is the hashes in %metadata being read-only. 20:20
guifa I’d definitely use a role. Here’s a quick markup 20:25
tio.run/##hY@xCoMwEIb3PMUhFtslgkMX...zmlxOArf0C
Sorry for ugly TIO link
gfldex lolibloggedalittle: gfldex.wordpress.com/2021/01/07/a-...ple-thing/ 20:31
20:32 ufobat_ joined 20:36 ufobat left
Tirifto guifa: Thank you! Forgot all about that beautiful operator, too. :-) But why do you think a role is a better fit than a class, in this particular case? 20:39
guifa a role propogates itself a bit better than a class 20:41
m: class A { method copy { A.new } }; class B is A { }; say B.new.copy.WHAT
camelia (A)
20:46 timlegge joined, timlegge left, timlegge joined
guifa eh, that example isn’t very good, role wouldn’t be different there 20:46
Tirifto Ah, just found out writing an example, too. xP 20:53
But other than that, do you think they make more semantic (is that the right word?) sense? 20:54
20:56 Altai-man left
Tirifto I’m thinking that when I’m dealing with a path to a file for my program to read/write, it’s a path to a special kind of a file… so adding a subclass makes semantic sense to me. But then again, it’s really the file that’s different, not the path that points to it. 20:59
21:03 v_m_v left 21:05 faisal_javed joined 21:07 timlegge left 21:09 timlegge joined 21:16 timlegge left
Geth doc: c661c55df0 | (Stoned Elipot)++ | doc/Type/Lock/Async.pod6
Fix whitespace in examples' code
21:18
linkable6 Link: docs.raku.org/type/Lock::Async
[Coke] who is elipot? 21:19
(here on IRC?)
Elipot, sorry
stoned75 I am. 21:20
Elipot is my last name
[Coke] stoned75: OHAI.
stoned75 Hi
[Coke] right, but If I ask "who is stoned", I'm setting it up for a humorous response. :)
stoned75 eh eh
guifa [Coke]: right so why didn’t you set it up for us? :-)
[Coke] do we have a standard on code ident? I know I've seen it done both ways. 21:21
21:21 timlegge joined
[Coke] I don't care either way, but we should probably document it if so, and maybe even add a test for it in xt/ 21:21
guifa Tirifto: Roles to me are the more natural fit when you’re just tagging on a small bit of functionality. Plus, there are other IO::Path subclasses, too, and you could apply the role to them (maybe you’ll get one without even knowing it!) and I don’t know how well they’d play with an unrelated subclass
stoned75 well if you refer to my last commit, it's only that having both a =begin code/=end code and initial 4 space indent is redundant and gives in the end a right-shifted code block 21:23
compare the alignment of code block in docs.raku.org/type/Lock::Async#method_protect and docs.raku.org/type/Lock::Async#met...-recursion 21:24
Tirifto guifa: Alright, I’ll see how it feels to use them! :-) Thank you for your advice. 21:25
stoned75 and then I supposed all examples in github.com/Raku/doc/blob/master/wr...XAMPLES.md are wrong :-} 21:26
21:28 rindolf left
[Coke] stoned75: ah, yes, we don't want the extra indent there. 21:29
I'll see about adding an xt/ test for that. 21:30
stoned75 I'll make a PR with an updated writing-docs/EXAMPLES.md
[Coke] stoned75++ Thanks!
stoned75 you're welcome
21:32 tech_hutch left
Tirifto Ah, looks like when a class’ or role’s attribute is a hash, its values are read-only, too. 21:33
(Read-only outside of the class/role, I presume.) 21:34
Geth doc/writing-docs-indent: 0efc01dd62 | (Stoned Elipot)++ | writing-docs/EXAMPLES.md
Add a note about code block initial indentation

  ... and be consistent about it in the given examples
21:38
doc: stoned++ created pull request #3770:
Add a note about code block initial indentation
guifa Tirifto: if you’re trying to do using my code with .metadata = %( … ), you’ll need to add in a proxy, but that’s easy enough 21:42
Tirifto guifa: I guess I’ll add a level of indirection in the ‘metadata’ method. I just thought it didn’t look that pretty. :-) 21:44
…or so I thought, but apparently it’s whole-hash-only-readonly all the way down! 21:48
21:48 wamba left 21:55 maggotbrain joined
Tirifto p6: role IOMeta { my %stash{Str}; method metadata() { %stash{self.path}<indirection> //= Hash.new } }; my $path = ‘/usr/bin’.IO does IOMeta; $path.metadata = { ‘cookies’ => ‘milk’ }; 21:55
camelia Cannot assign to a readonly variable or a value
in block <unit> at <tmp> line 1
[Coke] oh, I just made a segfault using a modified raku test. 21:57
21:57 timlegge left
[Coke] ... crap, non-repro. 21:57
21:58 timlegge joined 22:00 JRaspass joined
Tirifto guifa: Sorry, but what kind of a proxy were you thinking of? ^ ^’ (Was it outside of the class, i.e. ‘$path.metadata<proxy> = %( … )’?) 22:01
kjpye lizmat: are you still around? 22:11
guifa Tirifto: one sec and I’ll send you the code example 22:20
Tirifto: see gist.github.com/alabamenhu/c3ccebd...5ab33a9a66 22:32
actually 22:33
duh
you don’t even need to complicate it that far
I just updated the gist and that should work okay 22:34
Tirifto guifa: Yeah, I just tried to do the same. xD 22:39
I had no idea there was such a thing as ‘return-rw’ though! 22:40
Seems like that’s another concept I’ll have to assimilate in Raku. 22:41
guifa Generally Raku errs on the side of immutability, with opting into mutabilit (same principle is seen with attributes and parameters)
22:42 ufobat_ left
timotimo except in datastructures :P 22:44
Tirifto So I suppose what’s going on here is that anything you add to the class’ Hash attribute in the class’ own method will be considered immutable like the hash itself… which is specifying the key to put a value at in the class won’t work, but doing it outside will. 22:46
tony-o thanks haskell 22:47
Tirifto Thanks guifa, too. Looks like I can move on now! xP 22:49
guifa timotimo: ha, indeed. But now thanks to lizmat++ we have Dicts and Tuples so they too can be immutable 22:58
timotimo indeed 23:06
23:12 notagoodidea joined 23:13 patrickb left 23:15 brtastic left
notagoodidea When calling `run` or `shell` we have to go through hoops to get the output or is it a more straight forward way than `$foo.out.slurp(:close).say`? 23:15
tony-o you can use qqx if you only care about the stdout 23:23
notagoodidea is it an risk vs `run` or `shell` besides not capturing STD_ERR? 23:26
The doc says "Look at run & Proc::Async for *better* ways to execute external commands" emphasis is mine. 23:27
tony-o I'd use run unless you're doing something with pools or other crap where you need async 23:28
notagoodidea No, I just want to launch a fairly straight forward command ie fzf from a raku script and get the output. 23:29
23:30 aluaces left
tony-o if it's just a quick script and you don't need to assure $? == 0 then qqx will be faster 23:35
m: qqx{df}.lines.say;
camelia (Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 2001904 8 2001896 1% /dev tmpfs 2011028 0 2011028 0% /dev/shm tmpfs 2011028 185016 1826012 10% /run tmpfs 2011028 …
tony-o oops 23:36
m: say +qqx{df}.lines;
camelia 22
notagoodidea I was thinking to try my hand to module by wrapping fzf maybe. In this case using `run` will be more robust so?
23:36 tech_hutch joined
tony-o yea, you can check the exitcode that way if fzf isn't available 23:38
notagoodidea And does zef provides something in the likes of the wheels of pip in python if I want to bundle fzf?
tech_hutch Does Raku have a C-style switch statement, or just gather? I thought I saw somewhere that it does, but I can only find gather in the docs 23:39
MasterDuke given/when 23:40
tech_hutch whoops, meant given
23:50 Tirifto left
timotimo yeah, only given; currently also no labels for arbitrary gotos 23:53
so no duff's device either
guifa What’s kind of cool though is that it’s very possible to create a C-style switch (that acts on int values) 23:54
Raku leaves it open to that, although I’m not sure if you can do it without digging into grammar ATM 23:56
(at least, if you want it to remotely performant, which would be the reason you’d want it I’m sure)