🦋 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.
Doc_Holliwood Dear diary. Today I learned about the repeated function. Please bless() all the good people developing this wonderful language. Amen. 00:06
thowe Hello 01:45
jdv79 anyone know of any non-core examples of making something that is awaitable? 02:01
leont has build such a thing, actually 02:18
leont (but apparently hadn't pushed it to github until now) 02:21
leont github.com/Leont/raku-actor/blob/m...or.pm6#L45 02:22
Though I guess that's cheating by essentially delegating the awaitableness to a Promise 02:23
jdv79 hmm, yeah - that's just Promise 02:32
thanks anyway. maybe i'll just "try some stuff":) 02:33
leont Implementing Awaitable::Handle doesn't look to hard 02:44
(famous last words)
stoned75 hello 06:56
moritz hi stoned75 07:25
AndyMcD Hello, sirs and madams. 08:07
i have been reading the raku site for information and came across this 08:08
docs.raku.org/language/ --> 403 Forbidden
AndyMcD figured to put it here and let someone know. if there is a better way to report it, please let me know and i will do so 08:08
cheers
rba AndyMcD: On which page was the dead link? 08:10
AndyMcD docs.raku.org/language/faq#I'm_a_P..._and_Raku? 08:11
then click the link " Language section of the documentation"
rba AndyMcD: btw this is the place to report issues. Do you like to open one or should I? 08:12
AndyMcD if its okay with you, could you do it please? i just started my work day, so i have stuff to get on with. 08:13
apologies for the laziness
rba AndyMcD: Only if you promise me to improve your raku skills today :-) 08:19
AndyMcD haha :) definitely working on it :) 08:25
lizmat clickbaits rakudoweekly.blog/2020/03/09/2020-...he-videos/ 09:32
[ptc] already took the bait 09:40
tellable6 2015-04-11T14:48:17Z #perl6 <raiph> ptc: www.reddit.com/r/perl6/comments/326...rg/cq8q0yq
2015-04-16T14:44:15Z #perl6 <[TuxCM]> ptc: github.com/travis-ci/travis-ci/issues/2978#
[ptc] lizmat++
lizmat /o [ptc] long time, no see online :-) 09:41
[ptc] o/ heh :-) Managed to get back online at G[P&R]W2020. 09:44
moritz lizmat++ 09:45
lizmat hopes [ptc] will be able to exercise their Raku muscles again 09:47
[ptc] hopes so too! 09:49
I already have ideas from the workshop. Just need some peace and quiet to start implementing them :-)
lizmat orders [ptc] some peace and quiet 09:50
moritz flips a round tuit to [ptc] 09:51
[ptc] hehe 10:01
rypervenche When writing my own submethod BUILD, should I be binding or assigning the values to my attributes? I have seen both examples in the docs. 11:51
lizmat rypervenche: do you expect to change the values after they've been BUILD ? 11:57
lizmat if not, then you could use binding 11:57
of you are going to change them, the easiest would be to assign
binding would save you one scalar container from being allocated 11:58
depending on how many times you create an object of such a class, that could be an optimization opportunity
jnthn The huge opportunity for binding is when you have an array or hash 11:59
Especially if it's a big one 12:00
lizmat jnthn: well, that actually hasn't been implemented yet, it only binds for scalars atm
jnthn Since assignment into a hash or array is a copying operation (so O(n)) while binding is O(1)
lizmat my first attempt at binding in those cases, produced some weird errors :-(
jnthn lizmat: He was writing his own submethod BUILD, so is fine :)
uh, if "he", shouldn't assume
lizmat they is easier :-) 12:01
jnthn Indeed.
Somehow my brain parsed "ryan" out of the nick...which isn't there at all...wtf brain
I used such binding in the MoarVM heap profiler to avoid copying many-megabyte native int arrays around 12:02
lizmat even if you know the gender, people unconsciously assign value to gender specifications
jnthn Which saves vast amounts of time and memory :) 12:02
lizmat m: class Point { has $.x = 0; has $.y = 0 }; Point.new for ^1000000; say now - INIT now # rypervenche 12:03
camelia 0.4616124
lizmat m: class Point { has $.x is built(:bind) = 0; has $.y is built(:bind) = 0 }; Point.new for ^1000000; say now - INIT now # using bound attributes
camelia 0.2738341
rypervenche lizmat: Ahh, no I won't be changing them. Good to know. I need to reread the docs on binding and starting using it in my code where allowed/necessary. 12:16
jnthn: Haha, it's all good. "they" is easier so you don't have to remember. ryper is actually a sort of French slang/pig latin of my name Perry. A fellow beardy guy. 12:19
SmokeMachine Hi guys! I was trying to use DB::MySQL with no luck… it cant find the dynlib… any advice? 12:55
El_Che SmokeMachine: install the mysqlclient-dev package or something similarly named? 13:07
rypervenche Is DBIish recommended for databases?
SmokeMachine I tried… (i forgod to mention I was tring to install it on macos)
rypervenche: I recumbent Red… :) 13:08
rypervenche Touché :P
El_Che SmokeMachine: with brew?
SmokeMachine Yes, with brew and from msql site… with no luck... 13:09
El_Che SmokeMachine: when I am on mac, I tend to work with containers 13:13
in order to walk around the mac pain for packages 13:14
SmokeMachine El_Che: I’ll try that when I get back home... 13:14
El_Che SmokeMachine: I meant docker for mac 13:15
tried podman (what I use on Linux), but it was just a docker proxy
docker desktop for mac
SmokeMachine Yes, I know… the mysql server was running on a container… I’ll try to test my code inside a container also... 13:16
El_Che ah, ok 13:17
just checking :)
El_Che SmokeMachine: tried stuff like export DYLD_LIBRARY_PATH="..." ? 13:18
SmokeMachine yes... 13:19
El_Che GMFA
(Great Minds Fail alike ;) )
rypervenche I was thinking much worse words... 13:20
SmokeMachine and that was happening with both DBIish and DB::MySQL... 13:21
El_Che rypervenche: that's why you can't have nice things
rypervenche That explains a lot :( 13:24
El_Che :) 13:26
rypervenche Question, I'd like to add a type constraint to a subroutine of an array of objects. I tried doing Classname:D @array, but I get an error: Type check failed in binding to parameter '@array'; expected Positional[Classname] but got Array ($[Classname.new(...)
Is it possible to do what I'm looking for? Or do people not usually put type constraints on arrays? 13:27
El_Che rypervenche: I type arrays, but nothing fancy 13:32
jnthn rypervenche: The array that you pass in also has to have a matching type 13:36
e.g. be declared with that type
SmokeMachine m: sub bla(Int @a) {}; bla Array[Int].new: 1,2,3,4; bla 1,2,3,4 13:41
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling bla(Int, Int, Int, Int) will never work with declared signature (Int @a)
at <tmp>:1
------> 3t @a) {}; bla Array[Int].new: 1,2,3,4; 7⏏5bla 1,2,3,4
SmokeMachine m: sub bla(Int @a) {}; bla Array[Int].new: 1,2,3,4; bla [1,2,3,4]
camelia Type check failed in binding to parameter '@a'; expected Positional[Int] but got Array ($[1, 2, 3, 4])
in sub bla at <tmp> line 1
in block <unit> at <tmp> line 1
SmokeMachine m: sub bla(Int @a) {}; bla Array[Int].new: 1,2,3,4; # bla [1,2,3,4] 13:42
camelia ( no output )
rypervenche jnthn: Ahhh, that did it. Thank you.
I've been wondering how to do that for a while. knowledge++
I have to say, even though Python is seen as one of the easiest programming languages to learn, I had trouble understanding OOP and classes and methods (too many parentheses and "self"). I'm rather surprised and happy that I've picked it up as easily as I have in Raku. The syntax is much easier to understand and OOP finally makes sense to me. 13:44
moritz rypervenche: that's great to hear, thanks! 13:53
masak in my humble opinion, OOP never really truly "makes sense" :P 16:05
Grinnz the actor model is a good abstraction for it IMO 16:06
it's a thing, that can hold stuff, and do stuff
moritz IMHO there are problems that fit so well into our OO models that I feel it "makes sense" 16:07
and then there are things don't fit at all with our OO modeling techniques 16:08
Grinnz OO certainly has been misused or overused across the years 16:09
lizmat if you have a system in which not everything is an object to begin with, I'd agree :-)
tadzik I think that part of the misuse and misunderstanding of OO stems from the focus on the syntax in the first place 16:19
people then go "great, I learned classes, that was the next step after variables and functions" and then spam them everywhere because why level up if you don't exercise yuor skills after that 16:20
Grinnz i blame java :)
tadzik I blame C++, perhaps because I learned it first :P
ironically, one of the things that helped me *understand* OO was C, Gtk+ specifically 16:21
it has objects, but it doesn't have classes. You pass structs around, but you never look inside them, and afair the documentation doesn't even tell you what's inside them. You accept that they're opaque and that's iet 16:22
jdv79 it gets worse when someone learns any "patterns". all of the sudden everything is poorly poured into a "pattern". 16:41
Altreus lizmat: did you have a chance to ponder on my suggestions for ObjectCache? 16:47
kawaii Does Raku compile/work on the Windows Subsystem for Linux? 17:25
I find myself booting into my Windows partition of my laptop more in the evening, would be nice to be able to work too. 17:26
Altreus ssh 17:27
synthmeat is there a way to have lazy reduce? i.e. `[&&] ^1e1000`? 17:57
lizmat Altreus: I'm afraid I missed any ObjectCache suggestions :-( 18:02
Doc_Holliwood kawaii: it does. runs fine 18:13
Doc_Holliwood synthmeat: I think not. Every reduction needs to culminate in a single value and that by definition cannot be lazy 18:14
jnthn If you want all the intermediate values, you can do the triangle reduce ([\&&] instead), which is probably lazy 18:25
synthmeat ok, so `[&&] 0..100000` takes a bit, but `[&&] (0..100000).reverse` is basically instant, which is all good. i imagined reduce as `0 && 1 && ... && n)`, but instead it's `(...(0 && 1) && ... && n)`, so that makes sense. right? 18:39
meaning, evaluation of reduce starts from the outermost, which is 100000 in this case? 18:41
moritz m: say &infix:<&&>.assoc 18:43
camelia No such method 'assoc' for invocant of type 'Sub+{Precedence}'
in block <unit> at <tmp> line 1
synthmeat i don't know. my expectation was for `[&&] 0..100000` to finish fast, and `[&&] (0..100000).reverse` to take a bit. && is left to right, right? 19:26
lizmat synthmeat: (0..N).reverse is I believe statically optimized to N..0 19:29
so shouldn't really have a difference in performance 19:30
lizmat but quite possibly I'm out of date or wrong in that respect 19:30
synthmeat no, i mean `0 && 1 && ... && n` will finish fast at `0 &&` already. `n && ... && 1 && 0` has to go through all the way, and that's why it's taking longer. but it appears to work in opposite manner (in repl, anyways) 19:35
(unrelated, any convenient method to time the execution in repl?)
but `[*] 0..100000` is faster than `[*] (0..100000).reverse`, which aligns with my intuition 19:43
i'm not understanding something here badly ^_^
lizmat synthmeat: I don't use the REPL, I use an alias: alias r='time raku -e' 19:44
lizmat it allows me to run code like: r 'say 42' 19:44
and get timing info at the same time
[Coke] wonders how long his irssi executable has been missing while he was running it. oops 19:47
synthmeat lizmat: and what does `r '[*] 0..100000'` do for you? error over here, something about sink context 19:49
lizmat the r should be outside of the quotes 19:50
[Coke] coming in late, but you have to do something with the result, e.g. "say" it.
lizmat and NOT in the REOLK
*REPL
[Coke] defers to liz
synthmeat no, `` are conversational quotes here, as i use them 19:51
[Coke] just watched www.video.uni-erlangen.de/clip/id/12901, good to see some people again.
lizmat what [Coke] said :-)
El_Che lizmat: funny to watch you type and waching your presentation at the same time :)
[Coke] m: 3
camelia WARNINGS for <tmp>:
Useless use of constant integer 3 in sink context (line 1)
[Coke] ^^ same error.
synthmeat k
[Coke] basically, if you go to the trouble to do something, and then ignore it, the compiler assumes that's a bug. 19:52
er, not a bug, per se, but something to worry about. :)
synthmeat ok, so `[&&] (0..1000000).reverse` is 10 times slower than `[&&] 0..1000000` 19:53
s/slower/faster 19:54
lizmat is seeing the same 19:55
synthmeat but `[*] 0..1000000` is many magnitudes faster than `[*] (0..1000000).reverse`
lizmat interesting... 19:56
synthmeat and both * and && are left to right and expected to "fail fast" (so i don't abuse "lazy" term)
[Coke] [*] has a range optimization.
m: (0..10000000).^name.say
camelia Range
[Coke] m: (0..10000000.reverse).^name.say 19:57
camelia Seq objects are not valid endpoints for Ranges
in block <unit> at <tmp> line 1
[Coke] m: (0..10000000).reverse.^name.say
camelia Seq
[Coke] ^^ with a Seq, you have to go through the whole thing. with a range, you can cheat (and we do)
(now watch, we're not cheating and I'm remembering something from parrot) 19:59
Doc_Holliwood A company next village is offering a PHP position. Tempting benefits and easy too reach, but frankly, I'd rather jump into an ant pit with my gut sliced open. 20:00
lizmat mental health insurance included ? 20:01
Doc_Holliwood Maybe I should write them anyway, see if they have heard of this promising new language ...
synthmeat [Coke]: ok, when i convert them both to lists, perf seems exactly the same. that jives (kinda. i'm assuming there's a reason it doesn't stop at first item and just say `0`) 20:04
[Coke] that would be a better cheat! 20:06
[Coke] (but would probably slow down the general case if we had to add a compare to each element) 20:07
rypervenche Nice. I converted my password manager script from Bash to Raku: gist.github.com/rypervenche/234611...ed1788d61f 20:12
lizmat rypervenche: if you add "is built(:bind)" to each attribute definition, you can drop the BUILD method completely 20:15
rypervenche Oooh
Before or after the "is required" or does it not matter? 20:16
MasterDuke gist.github.com/rypervenche/234611...ku-L80-L83 could probably be `return @input.first(*.site eq $chosen-entry-name)` if you wanted 20:17
rypervenche Oooh, also a nice shortcut. Thanks.
MasterDuke why are you doing `.lines.join("\n")` here gist.github.com/rypervenche/234611...ku-L88-L92 ? 20:19
rypervenche That....is a good question.... Let me try it without and see what it gets me, but it should be the exact same thing without it... 20:21
Yep, I don't know what I was thinking there. Removed it. 20:23
And cool, looks like order of the "is" parts doesn't matter. 20:24
MasterDuke fwiw, i'm not 100% sure if `.lines.join("\n")` will treat windows/mac/*nix newlines all the same as just doing nothing. may depend on what you pass it to whether it matters (if it's not the same) 20:25
rypervenche That's true. I only use Linux and am only writing this for myself, (at last for now). These are also little projects for myself to learn more of the language. 20:26
So thank you very much for the feedback.
MasterDuke np
rypervenche This is really the only place I can chat about Raku. :P 20:27
synthmeat you can always talk to yourself though 20:32
rypervenche >< 20:36