🦋 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.
rypervenche Is it possible to output bytecode into a file? Like using --target=mbc ? I tried that but got: Cannot dump this object; no dump method 01:41
timotimo rypervenche: did you also give it a --output=blah? 03:15
MilkmanDan imgur.com/gallery/Wa45rla 04:36
Altreus lizmat: I put them on github :D 09:14
lizmat Github is a big place 09:15
Altreus your repo is a small one though :)
Altreus github.com/lizmat/ObjectCache/issues 09:15
lizmat found them :-) 09:16
lizmat Altreus: new version of ObjectCache, with evict capability, on its way to CPAN 09:42
Altreus woot! 10:19
also TFW you don't notice your SSH has disconnected
even though you closed your laptop for half an hour and changed networks
> The `!EVICT` method returns the object that is removed from the cache, or `Nil` if the object was not in the cache. 10:21
This is why liz code is quality code
I've recently opened an issue on something else that does not behave along a similar pattern 10:22
forgot what mind you
lizmat :-) 10:41
Altreus Now I can cache my ButReals and uncache them if I want to be sure of re-fetch 10:59
and the way you force a re-fetch is to evict it
nice nice
Later
:(
lizmat method re-fetch() { self!EVICT; self.bless(id => $!id) } 11:04
method re-fetch() { self!EVICT; self.bless(:$!id) } # shorter :-) 11:05
Altreus self!EVICT; self.fetch 11:14
:P
lizmat self!EVICT.fetch even :-) 11:18
assuming you're sure the object wasn't evicted before :-) 11:19
Altreus can't be
User might de-cache it Just In Case
honestly I think I might just have uncache as a separate thing 11:20
Then the user can say what they mean
After all, the cached thing is an Object::Delayed, so fetch might not be the thing they do
lizmat hmm... but Object:Delayed needs a container, ObjectCache doesn't give containers ? 11:21
Altreus Indeed, I'll be caching the ButReal 11:23
There are layers going on :)
The idea is that you can freely create the top-level object, which really only has an ID and an Object::Delayed property
Once instantiated, that property now contains a data object that is in the ObjectCache 11:24
That way, if you do (for example) Channel.new(1234), then when you access any data from that channel, the Object::Delayed runs a constructor, which is cached
If it isn't cached, the constructor fetches it
in theory! 11:25
rypervenche timotimo: Yes, I did give it an --output like that. Same error.
theovdh Hi gurus, getting: 'Cannot find method 'has_hook' on object of type NQPMu' when debugging big program containing Grammar. Suggestions? 11:40
lizmat you could start by making a gist of the output of the stack trace when run with --ll-exception 11:45
theovdh thanks @lizmat 11:51
rypervenche timotimo: Ahh, I think I kind of found my problem. I ran --target=mbc on a script that doesn't expect input and that works fine. I guess it doesn't work if it expects user input. 12:01
timotimo rypervenche: hum, the script you're using it on shouldn't make a difference i think? 14:26
rypervenche: can you give the exact commandline you're using? 14:27
perl6 --target=mbc --output=blah.moarvm -e 'say "hello world"'
^- this works for me
rypervenche Ahhh, it doesn't seem to work with -o, but does work with --output. I've tried: raku --target=mbc -o /tmp/blah.moarvm ./script.raku and also with -o=/tmp/blah.moarvm 14:37
timotimo maybe "-o blah" not working is something we can fix 16:00
rypervenche I'll submit an issue to rakudo then. 16:23
kawaii I have the following snippet of code I'm a little confused about - I've got a subroutine (`start-vote`) which returns a promise which is supposed to last for 60 seconds. It's my understanding that using `.then` means whatever you feed it doesn't happen until something you're awaiting has completed - but all of these things in the code sample just trigger at the same time 16:49
gist.githubusercontent.com/kawaii/...e9/test.p6
AlexDaniel kawaii: but you're not doing .then on start-vote 16:58
kawaii: you're doing it on send-message, no?
kawaii AlexDaniel: you're right, it's triggering _both_ `.then`'s at the same time 16:59
nice catch, thanks
I need to chain them
AlexDaniel point is I don't see where you call start-vote and if you do at all
aahhh I see now 17:00
right, you're doing .then on the wrong thing :)
AlexDaniel for example, it can be inside the parens 17:00
kawaii Yep, I fixed it, thanks :) 17:03
AlexDaniel kawaii: also why don't you just put that whole thing into a react block or something 17:04
you can do whenever Foo { whenever Foo { whenever Foo { } } }
jnthn: btw what's the right way to have whenevers outside the lexical scope? 17:05
jnthn: some of my programs are just… uh… a single react block
sure I can call subs from whenevers but then I don't have the ability to just plug a whenever anywhere in my code
which I do a lot
IIRC it was possible earlier but then we figured out it was accidental and is not supposed to work, but now I really want it :D 17:06
kawaii AlexDaniel: this is really the first thing I've done which makes use of Promises and async in P6, still not entirely sure I'm doing things right but solving one problem at a time 🥴 17:07
gist.githubusercontent.com/kawaii/...voteban.p6
It looks messy but... small steps :) 17:08
AlexDaniel kawaii: it's weird to see .then. Just use react? 17:09
react { whenever ….send-message { whenever start-vote { say ‘ok we're done!’ } }} 17:10
alternatively just make start-vote blocking, you're using it as such anyway
kawaii 🤔
AlexDaniel our docs for react really suck, actually 17:12
we should be advertising it throughout all doc pages
there's this monster example here: docs.perl6.org/type/Proc::Async 17:13
jnthn AlexDaniel: Factor some of them out to separate `supply` blocks, and `whenever` those 17:16
AlexDaniel jnthn: that may sound easy but in reality it requires some refactoring which I'm not always willing to do :S 17:17
I guess I just need to make a module for myself :) 17:18
it's a common problem when you're dealing with timed sequences of things 17:21
“do this, then sleep, then do that”, but oh wait can't really sleep here
dakkar what's wrong with `await`? 17:22
lizmat dakkar: it's more plumbing than porcelain ?
AlexDaniel dakkar: are you talking about kawaii's code or my problem? :)
dakkar really?
lizmat because you can use a promise in a whenever 17:23
dakkar if I need to go through a sequence of non-blocking calls, `await first-thing();await second-thing();` looks nice to me
`whenever` feels more apt for things that can happen more than once
lizmat m: react whenever Promise.in(3) { say "waited" } 17:24
evalable6 waited
AlexDaniel dakkar: that doesn't make any sense if you have other async events happening
surely you can `start` everything, but then you get all the usual problems
dakkar AlexDaniel: true
(also I can't find examples in my code where I use `await`, but plenty of `whenever`, so maybe I'm just confused today ☺) 17:27
SmokeMachine Hi there! Is there a way of finding what attributes a method use?
moritz SmokeMachine: I'm not aware of one 17:28
SmokeMachine moritz: thanks! Wouldn’t that be good? Find what attributes a method use, what outside variables a closure use... this kind of thing... 17:30
lizmat I think this goes back to a discussion jnthn moritz nine and I had before the GPaRW 17:33
we lose too much introspection opportunities during compilation
*many
SmokeMachine I was trying to find a way of making something like: `class C { has $.a = 2; has $.b is some-trait = $!b + 2 }` and when I do something like: $!a = 40, $!b would be automatically 42...
dakkar (nitpick: you can detect which attributes a method *could* access (i.e. which are mentioned), not exactly which ones it really accesses (since the latter reduces to the halting problem)) 17:34
jnthn SmokeMachine: Those kinds of things wait for us to have a user-visible AST, which is part of the macros work. I'm doing some initial experimenting in that area. 17:35
SmokeMachine jnthn: great! But that would be possible with a macro? Should the Attribute.build be a macro for that? Or will it have a way to get the ast from a given method from outside of a macro? (Sorry, just trying to understand...) 17:39
dakkar: I meant mentioned... :) 17:41
moritz SmokeMachine: btw Math::Model solves this problem by having the user write functions that take named args, and you can introspect those
moritz perlgeek.de/blog-en/perl-6/physica...lling.html 17:42
y_acceleration => { $:force / $:mass },
lizmat
.oO( only one more Rakuer, and they're all not found: www.reddit.com/r/rakulang/ )
17:43
jnthn SmokeMachine: Current thinking is that it'll be possible to obtain the AST up until CHECK time. So for example a trait on a routine could get the AST of the routine. 17:47
SmokeMachine moritz: looks good (I do something similar here (github.com/FCO/ProblemSolver/blob/...y.p6#L16)) but wouldn’t it be better to just do `has $.y-acceleration = $!force / $!mass`? 17:48
jnthn: cool! 17:49
SmokeMachine jnthn: something like this? #`(inside trait code) &attr.build.GET-AST # or whatever it’ll be called 17:54
jnthn: I mean, will it be like a method on Routines?
jnthn Probably along those lines, though I doubt you'll have to shout it :P 17:56
SmokeMachine :)
It will make Red’s life much easier! :) 17:57
melezhik Hi! I launched a beta version of SparrowHub - repo.westus.cloudapp.azure.com/hub/ , I'd interested to hear about what kind of plugins could be useful for Raku community. Would appreciate for any feedback. Warning - some of the plugins could not work as a migration of Sparrow to Raku has not finished yet. 19:33
jnthn melezhik: Ah, is that the cro app you've been writing recently? :) 20:10
melezhik yeah, I rewrote former SparrowHub to Raku/Cro making some system redesign on the way 20:11
basically it's just UI to search/read docs on "official" sparrow plugins (github.com/melezhik/sparrow-plugins) 20:12
as well as main repo
tbrowder i need some advice for a much simpler problem: given a routine to return the fractional part of a number, for an integer input should it return undefined (Any) or zero? 22:56
lizmat what is the type of the fractional part it returns if it is *not* an integer? Str or Int ? 23:01
tbrowder as i have the routine coded now, i check for the input type and eventually the input, if not an integer, will be a Num. 23:09
and in that case the frac part becomes undefined for an allomorph input as "1.0" 23:11
tbrowder looking at all my test cases as input, i'm leaning toward zero in all cases including int input. 23:13
tbrowder given my main use case as a string input of base other than dec, oct, hex, or oct, then zero makes more sense to me if the string either has no radix point or has nothing other than zeroes after the radix point. 23:16
*oct => binary 23:17
AlexDaniel tbrowder: what does it return for 1.0001 ? 23:26
tbrowder 0001 (radix point implied) 23:27
AlexDaniel and what's the type of that?
tbrowder str
Str 23:28
AlexDaniel so why would you return a zero instead of an empty string if you always return a string?
tbrowder i'm looking at a caller testing for the fractional part so, with no number of value after an existing radix point, or a nonexistent radix point, the return value should be falsy imho: either zero or '' or undefined. 23:33
"does it matter" i guess is my question.
AlexDaniel "who needs that" is mine 23:34
tbrowder er, i do, for the moment.
just "testing the warer 23:35
*water"