🦋 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 hi, #raku 10:40
tbrowder just learned the value of routine "clone" after spending WAAAy too much time debugging a class that i couldn't add a hash to its rows attr without the hash losing its contents. 10:43
color me stupid for that not being a clue but i have never used clone before and i only remembered it by searching for "raku deep copy" and up popped words about damian and perl and "clone" and bingo! case solved. whew! 10:46
lizmat :-)
tbrowder all along i thought raku would just handle it cause every thing is an object, and simple cases all worked ok which lulled me into false sense of security. 10:49
morning, lizmat! why doesn't raku automatically do the clone?
lizmat could you show the code that lulled you into a false sense of security ? 10:50
tbrowder yes, it will take a while, a few errands to do after this strenuos exercise. the effort is to help me in tax prep taking a csv file from a finance record dump and rewriting into proper form for irs and accountant. should be relatively simple, but was i wrong--alice and the rabbit hole... 10:54
lizmat ;-(
tbrowder be back in a while...bye
oh, i am using tony-o' CSV::Parser which works fine after i learned how to work with it (i need to study his tux slang info...) 10:56
hungrydonkey l 12:13
AlexDaniel jmerelo: can we finaly get a redirect from docs.perl6.orgdocs.raku.org? I keep hitting old links 13:43
tellable6 AlexDaniel, I'll pass your message to jmerelo
AlexDaniel jmerelo: mainly from my own browser history, but it's really annoying
tellable6 AlexDaniel, I'll pass your message to jmerelo
chloekek p6: my $x𓀀 = 1; say $x 14:52
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$x' is not declared
at <tmp>:1
------> 3my $x𓀀 = 1; say 7⏏5$x
chloekek p6: my $𓀀 = 1; say $𓀀
camelia 1
chloekek Nice.
unidump: 𓀀 14:54
unicodable6 chloekek, gist.github.com/d652b635db67672382...6020b1e516
tbrowder m: my %h=2=>1,10=>2;say %h.keys.sort 15:15
camelia (10 2)
chloekek p6: my %h{Int} = 2 => 1, 10 => 2; say %h.keys.sort 15:17
camelia (2 10)
tbrowder m: my %h=2=>1,10=>2; say %h.keys.map({my $a=$_;$a.=Int}).sort 15:17
camelia (2 10)
tbrowder chloekek: thanks. yrs works when you have access to the declaration. i was passed the hash after construction 15:22
chloekek p6: my %h = 2 => 1, 10 => 2; say %h.keys.sort(&[<=>]) 15:23
camelia (2 10)
chloekek p6: my %h = 2 => 1, 10 => 2; say %h.keys.map(+*).sort 15:24
camelia (2 10)
tbrowder thnks, that's what i was looking for! but is there an easy way to convert a passed hash to int keys? 15:27
tbrowder even better! you should add those examples to the docs!! 15:29
tobs m: my %h = 2 => 1, 10 => 2; dd %h.&{ my %{Int} = +«.keys Z=> .values } # optimized for funny symbols 15:33
camelia Hash[Any,Int] % = (my Any %{Int} = 2 => 1, 10 => 2)
chloekek p6: my %h = 2 => 1, 10 => 2; my %i{Int} = %h.pairs.map({ +.key => .value }); say %i.raku 15:38
camelia (my Any %{Int} = 2 => 1, 10 => 2)
poohman m: "M00".Int !~~ Failure 15:54
camelia ( no output )
poohman If I use something like this in code, a warning is generated 15:57
m: if ("M00".Int !~~ Failure) then return True; 15:58
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3if ("M00".Int !~~ Failure)7⏏5 then return True;
expecting any of:
block or pointy block
infix
infix stopper
poohman m: if ("M00".Int !~~ Failure) then {return True};
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3if ("M00".Int !~~ Failure)7⏏5 then {return True};
expecting any of:
block or pointy block
infix
infix stopper
poohman m: if ("M00".Int !~~ Failure) {return True}; 15:59
camelia ( no output )
poohman the WARNING Im getting is -> Unhandled Failure detected in DESTROY 16:02
how can I avoid this? 16:03
m: if ("M00".Int !~~ Failure && "N00".Int !~~ Failure) {return True}; 16:07
camelia ( no output )
poohman The problem is that writing this warning each time to the slows the execution considerably 16:08
poohman m: if ("M00".Int !~~ Failure).Bool {return True}; 16:14
camelia ( no output )
poohman a .Bool seems to supress the warnings 16:15
was too soon - that didnt work either
Geth doc: af50b53198 | (JJ Merelo)++ | 2 files
:delete working on lazy arrays #2632
16:30
linkable6 DOC#2632 [open]: github.com/Raku/doc/issues/2632 [Hacktoberfest][RFE][big][docs][good first issue][help wanted][new][⚠ Top Priority ⚠] Checklist for 6.d
MasterDuke poohman: does `quietly` help with what you're trying to do? 16:43
poohman MasterDuke: let me try reading about that 16:56
strange- that does not seem to help as well 17:02
timotimo m: without "M00".Int { return true } 17:05
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
true used at line 1
timotimo m: without "M00".Int { return True }
camelia Attempt to return outside of any Routine
in block <unit> at <tmp> line 1
timotimo m: without "M00".Int { say "it was a failure, oh no" }
camelia it was a failure, oh no
timotimo m: without "".Int { say "it was a failure, oh no" }
camelia ( no output )
timotimo m: say "".Int
camelia 0
timotimo if that's acceptable to you
poohman timotimo 17:07
:
The problem is that if I use "M00".Int or $a.Int and if $a turns out to be non numeric I get a runtime error and execution stops 17:08
that is why I introduced a check 17:09
timotimo m: sub testsub { say "M00".Int; say "survived?" }; try { testsub }; say "eop"
camelia eop
timotimo m: sub testsub { say "M00".Int; say "survived?" }; testsub; say "eop"
camelia Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5M00' (indicated by ⏏)
in sub testsub at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo ^- exception handling can help you by causing the Failure object to be thrown 17:10
poohman ok thats one route to take
timotimo the direct inside of a try block will also have "use fatal" active, which causes things to explode more quickly 17:11
m: sub testsub { use fatal; my $res = "M00".Int; say "result obtained"; say "result is $res" }; testsub
camelia Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5M00' (indicated by ⏏)
in sub testsub at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo m: sub testsub { my $res = "M00".Int; say "result obtained"; say "result is $res" }; testsub 17:12
camelia result obtained
Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5M00' (indicated by ⏏)
in sub testsub at <tmp> line 1
in block <unit> at <tmp> line 1
timotimo ^- see how in the second one, without the "use fatal", the "result obtained" line still runs
poohman ok 17:14
timotimo m: say try "M00".Int 17:15
camelia Nil
timotimo ^- you can also use try without making a full block out of it
patrickb ping tadzik 17:20
tadzik patrickb: oh hey :) 17:31
tadzik patrickb: so, would you be okay with something like "this project is no longer maintained, you should probably use [rakubrew] instead" in the readme? 17:31
patrickb tadzik: My question was an open question. It's just that *if* we decide to have rakubrew as the official successor and consequently deprecate rakudobrew, then the links on raku.org and rakudo.org should be changed and like you said add some text to the rakudobrew repo. 17:36
SmokeMachine hi guys! I'm getting some strange errors while running a code with .race (without the .race it works 100% of the time)... it works 80%ish of the tries, but it can break with 3 different errors... it seems a bug... is it? gist.github.com/FCO/47c1db273cfb49...702f695803 17:38
jnthn SmokeMachine: Normally means a hash is being unsed unsafely (maybe an array too). I wonder if `is cached` (which is experimental, try removing use of that) is threadsafe. 17:40
SmokeMachine jnthn: yes... no errors until now without the is cached trait... 17:42
patrickb tadzik: But yeah, something like that in the readme would be sensible. 17:45
SmokeMachine jnthn: would this be the best way of doing that? gist.github.com/FCO/9083a5f04dba5f...b0f130724f 17:49
AlexDaniel chloekek: oh, I didn't expect 𓀀 to work 17:53
chloekek :) 17:54
AlexDaniel “Lo” category, hmm
AlexDaniel I guess it means that other… interesting characters… can also be used for variable names :) 17:54
tbrowder lizmat: after working up a detailed demo i cannot dup my original "problem". back to work on the original and see if i can make progress. will check in again if i can shed any light. 18:19
chloekek: i filed a doc issue on the hash key sort. if i get some time i'll try to add something to the docs. thanks for your help. the "map(+*)" trick is sweet and noise-free (at least to me). 18:22
Altreus Is there a reason not to create multiple supplies tapping the same supply, as opposed to creating a single supply and returning it? 19:14
Does that make sense
e.g. instead of having a $.messages property on my object and emitting onto it, have a method messages { supply whenever $!websocket.messages { ... } } 19:15
Is it worth saving supplies? :)
timotimo i'd say it is 19:18
Altreus k 19:21
emit is dynamic though yes? :)
eh I might just merge the methods
Altreus I did it like this then, rather than creating a new supply every time messages is requested github.com/shuppet/p6-api-discord/...n.pm6#L112 19:32
refactoring a lot because I'm tearing my hair out trying to figure out why it won't reconnect properly :( 19:33
timotimo sorry about that :< 20:11
Altreus hrm my refactor doesn't work but I don't understand why 20:12
Altreus I used to have something along the lines of: start react whenever { $websocket.messages { ... $!messages.emit($json) } } 20:14
Now I have $!messages = supply whenever $websocket.messages { ... emit $json }
and now I never seem to receive anything from the websocket 20:15
Altreus am I now blocking? 20:15
timotimo m: my $messages = supply { say "supply block!"; whenever Promise.in(4) { emit "lol" } }; $messages.tap(*.say); $messages.tap(*.say); $messages.tap(*.say) 20:17
camelia supply block!
supply block!
supply block!
timotimo ^- this could be your issue
tapping the supply runs the supply block again; you end with another supply each time anyway 20:18
try .share on the supply instead
m: my $messages = supply { say "supply block!"; whenever Promise.in(4) { emit "lol" } } .share; $messages.tap(*.say); $messages.tap(*.say); $messages.tap(*.say)
camelia supply block!
Altreus ah hmm
timotimo m: my $messages = supply { say "supply block!"; whenever Promise.in(2) { emit "lol" } } .share; $messages.tap(*.say); $messages.tap(*.say); $messages.tap(*.say); sleep 3
camelia supply block!
lol
lol
lol
Altreus I have much to learn :)
also, I think perhaps I am replacing the original supply with a new one 20:19
Because!
I can't set up the message supply until several WS message have arrived
Altreus Eh, maybe I can but I'll have to refactor more 20:19
DrGuifa is super blind.
Where is the definition for Raku’s Regex slang?
guifa . o O ( celebration time is mostly over haha ) 20:20
MasterDuke guifa: pretty sure it's all in nqp
guifa MasterDuke: I’m trying to do a work up for a binary regex and I wanted to follow standard regex grammar as closely as possible 20:21
aka ruthlessly and shamelessly copy and paste
MasterDuke github.com/Raku/nqp/tree/master/sr...ex/P6Regex is probably a good place to start 20:24
guifa Aaaaah. I was hunting around in rakudo rather than Raku on github
timotimo yeah, nqp lives outside the rakudo org 20:36
guifa Looking it over I might start by doing a baby implementation. There’s quite a bit to handle if I want to match it exactly, but the core of token + quantifier + basic grouping should be easy enough to handle in a simple grammar 20:38
Altreus OK, one of the things I did fixed my supply :D 20:41
I'm going to assume it was .shared
If nothing else at least the code is a bit more tidy 20:46
so people can help me with it <3
daemon :) 20:47
Altreus daemon: gonna watch stardew tomorrow? there may be awful scottish accents again 20:55
daemon Altreus, as long as it does not collide with my mp stream ;p
Altreus less important
daemon I found out earlier though that tf2 is pretty fun 20:56
not the default mode but the invasion mode
Altreus :)
let's not flood raku with strim chat tho 20:57
Altreus 'm off to bed while I wait for my bot to crash again 20:57
daemon :)