🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
SmokeMachine Is there a way to get the where condition from a subset? I’m thinking on a way of doing something like this: let’s say User is a Red model, then I’d like to be able to do something like this: subset Admin of User where *.role == “admin”; and that would work as usual and also, when you do Admin.^all, it would be equivalent of doing: User.^all.grep(*.role == “admin”); any idea if that’s possible? 00:29
(I know that .^all wouldn’t even work on that case because it’s using Metamodel::SubsetHOW instead of MetamodelX::Red::Model 00:32
Voldenet SmokeMachine: Admin.^refinement gets you WhateverCode which isn't too useful – in the simplest cases something like ix.io/3TYF could work 02:23
…afterwards I read the rest of the question only asking for `^refinement` 02:33
p6steve lichtkind: I found this github.com/lichtkind/Chart - 46.8k lines so i am not going to ask "please rebuild as raku" ;-) 07:28
p6steve All: is there any general f/back on direction of travel for raku plotting ... my default is Inline::Python matplotlib or ggplot ... but maybe a shim on Inline::Perl5 Chart better? 07:29
MasterDuke there are a couple raku plotting modules, but i don't think any are quite as feature-filled as matplotlib, etc 08:43
p6steve MasterDuke: my bad too lazy to look at raku.land(!) ... SVG::Plot (while a bit neglected) has some good prior art on the raku API needed for plot (and even has plot examples with Grammars!) 10:03
MasterDuke: so I will probably launch off that (may need to extend) for the pure raku side (then Inline::Python ```import matplotlib.pyplot as plt``` for backward compatibility and full features) 10:06
Xliff \o 10:59
What's the best way to get the maximum value for a num64?
MasterDuke the max value is infinity, so not sure what you mean? 11:12
Nemokosch then the max finite value I guess 11:18
I'm rather curious about what num64 is
MasterDuke it's a sized native num, though Num is just a wrapper around them and there really isn't much of a difference 11:20
it's just a double under the hood 11:21
Xliff MasterDuke: A google search gave that value to be something like 7976931348623157e308 11:44
That's actually: 1.7976931348623157e308 11:45
melezhik . 11:49
Nemokosch How does the $! variable work exactly? It reminds me of IOResult in Turbo Pascal
I had a process that failed. When I logged $! right after the try clause, things went on as usual. When I tried to postpone it after other calls, I failed
other calls NOT inside the try clause, that is
or is run implicitly async? 11:53
something is off here
moritz there are two ways to handle errors: one is a CATCH block, where the error object is available as $_. Note that you don't need any 'try' for that, because the presence of a CATCH block already marks it as an error handler 12:01
the second is to use `try`, which catches all errors, and sets $!. $! shouldn't be reset unless by another (or this) try block 12:02
Nemokosch I think I'm facing some async issue with `run`. 12:33
from what I see, the clever thing is to not run `run` itself in sunk context 12:39
moritz or use Proc::Async, which is, like, async by itself :D 12:40
Nemokosch The reason people choose `run` over Proc::Async is that Proc::Async is overkill for certain tasks 12:44
ugexe sinking a failure raises an exception 13:20
[Coke] I am close to writing a wrapper for Proc::Async because I use it a lot in my scripts for work. 13:22
jgaz [Coke]: You use Raku in production? Very cool. 13:25
[Coke] mm. I am not sure how much help a wrapper would be. I tend to have a list of things to process, run them all async collecting the output (so in a hash, with a lock), and then process the resulting output. Not sure how much of that is helpfully abstracted, and how much cleaner I can make the syntax. 13:29
(and if I did have a wrapper, doing anything other than that particular approach then becomes harder. Might be better to just writeup a sample explaining the usage.) 13:30
(which itself is cribbed together from poking people on this channel.)
nine has been using Raku in production for years 14:42
It's the reason for the drive towards 0 segfaults in the same time span 14:43
holyghost re 14:46
Gremlin Scheme (old racul) now can store variables of the form "(define x 5)" at runtime, it's at 2100+ lines and available here : sourceforge.net/projects/gremlin-scheme/files/ 14:47
Later on I will pull it towards a Scheme for raku extension, just as guile for GNU software 14:48
See for the gremlinscm_dispatch_symbol method
The system will have a bootstrappable library for talking Scheme with the runtime
There is an API now for symbols and the theorem prover 14:49
Instead of using BNF or something, it uses an inference/rule system to parse for the Scheme system
Be patient, and I'll be too :-) 14:50
ugexe run is a wrapper for Proc::Async 15:54
a generalized wrapper anyway 15:55
although it sounds like you are talking more about a Process Manager than a wrapper
Voldenet p6steve: I've used Chart::Gnuplot and despite some minor pains it worked relatively well 16:49
p6steve Voldenet: tx! 17:02
Voldenet iirc by default it didn't support pngcairo though 17:03
Voldenet so i had to remove package maintainer-provided gnuplot and use the one from debian's repo 17:04
Xliff \o 19:20
Does Num have a wau of getting its floating point portion?
sub a ($f) { $f - $f.floor}; say 19.3333.&a 19:22
evalable6 0.3333
Xliff Eh. That's not so bad.
Voldenet actually 19:23
m: sub a ($f) { $f - $f.floor}; say -19.3333.&a
camelia -0.3333
Voldenet uh what?! 19:25
m: sub a (Num $f) { $f - $f.floor }; say -19.3333.&a
camelia Type check failed in binding to parameter '$f'; expected Num but got Rat (19.3333)
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Voldenet m: sub a (Num $f) { $f - $f.floor }; say -19.3333.Num.&a
camelia -0.33330000000000126
Voldenet m: sub a (Num $f) { $f.floor }; say -19.3333.Num.&a
camelia -19
Voldenet Why does floor do truncation? 19:26
Xliff Coz .floor is a truncation?
Voldenet Nope, floor and ceiling are very well-defined 19:27
Xliff OK, then. I thought floor gave only the integer part of ther number. Effectively cutting off the floating point value. 19:28
Voldenet in fact, I wonder why the output is -19 in this specific case, it's weird
drakonis can nativecall be extended for usage with other languages?
Xliff Um. Would floor of -19.333 be -20?
Voldenet Yes, for -19.333: floor = -20, ceil = -19, trunc = -19 19:29
Xliff drakonis: As long as that language can output to the system-level shared library format, I think so.
drakonis i see
should be fine then
Xliff Voldenet, Um.... bug?
Voldenet I'm very much convinced that this is a bug, since there exists method called /truncate/ 19:31
m: sub a (Num $f) { $f - $f.truncate }; say -19.3333.Num.&a
camelia -0.33330000000000126
Voldenet and this is valid
MasterDuke nqp: say(nqp::floor_n(-19.333)) 19:33
camelia -20
Voldenet …and this is also valid!
Xliff Er. Ouch.
If raku and nqp differ, then that is definitely a bug! 19:34
MasterDuke m: say (-19.333).floo
camelia No such method 'floo' for invocant of type 'Rat'. Did you mean any of
these: 'floor', 'flat', 'flip', 'log'?
in block <unit> at <tmp> line 1
MasterDuke m: say (-19.333).floor
camelia -20
Voldenet m: say (-19.333).Num.floor 19:35
camelia -20
Voldenet m: sub a (Num $f) { say $f }; -19.3333.Num.&a 19:37
camelia WARNINGS for <tmp>:
19.3333
Useless use of "-" in expression "-19.3333.Num.&a" in sink context (line 1)
Voldenet m: sub a (Num $f) { say $f }; say -19.3333.Num.&a
camelia 19.3333
-1
Voldenet ಠ_ಠ
what is happening
MasterDuke m: sub a (Num $f) { say $f }; say (-19.3333).Num.&a 19:38
camelia -19.3333
True
Voldenet …oh.
That is totally not a bug, just unexpected syntax. 19:39
sub a ($f) { $f - $f.floor}; say (-19.3333).&a
evalable6 0.6667
Voldenet and as expected, this gives you wrong result
SmokeMachine Just laughed a new Red release! Now it's on fez and accepts columns as arrays and typed arrays! No need to manually define the database type for those! 20:37
japhb SmokeMachine: Just *launched*? 21:07
SmokeMachine exactly! my English is not that good and the auto corrector do not help! :) 21:09
moritz laughing a release into existance also sounds like a fun development process :-) 21:18
melezhik .tell patrickb I have added GH authentication to sparkyci, eventually will add ability for users to setup their repositories via accounts 22:29
sparrowhub.io:2222/login-page 22:30