🦋 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: ... | Logs can be inspected at colabti.org/irclogger/irclogger_log/raku
Set by lizmat on 21 April 2021.
00:01 kurahaupo left 00:04 kurahaupo joined 00:05 Kaiepi joined 00:11 swaggboi left 00:13 kurahaupo left 00:18 moony left 00:19 kurahaupo joined, swaggboi joined 00:23 kurahaupo left 00:24 kurahaupo joined 00:30 rindolf left 00:38 Kaiepi left 00:40 moony joined 00:41 kurahaupo left 00:49 kurahaupo joined 01:06 netrino left 01:14 moony left 01:21 camelia_ joined 01:27 b2gills joined 01:52 kvw_5 joined 01:54 lizmat joined 01:55 kvw_5_ left 02:02 moony joined, camelia_ left 02:21 solitario left 02:22 bloatable6 joined 02:25 solitario joined
xinming m: my %a = :a(1), :b(2); my %b = %a<>:p.map({ .value => .key }); %b.raku.say; 02:36
camelia {"1" => "a", "2" => "b"}
xinming Can we have shorter version of this? 02:37
the %a<>:p.map({ .value => .key }) thing
02:39 Util joined
raydiak m: say {:a(1), :b(2)}.antipairs 02:49
camelia (1 => a 2 => b)
03:19 stoned75 left 03:21 stoned75 joined
xinming thx 03:25
:-)
03:40 guifa2 joined
raydiak you're welcome :) 03:42
03:49 kurahaupo left, kurahaupo joined 03:51 Kaiepi joined 04:01 wamba joined 04:19 guifa2 left, kurahaupo left 04:23 guifa2 joined 04:36 kurahaupo joined 04:40 kurahaupo left 05:12 guifa2 left 05:24 kurahaupo joined 05:47 kurahaupo_ joined 05:51 kurahaupo left 05:59 parabolize left 06:11 sivoais left, eseyman left 06:14 eseyman joined 06:39 sivoais joined 06:50 patrickb joined 07:04 abraxxa joined 07:05 abraxxa1 joined 07:08 abraxxa left 07:16 asymptotically joined 07:26 ufobat joined 07:27 aborazmeh joined 07:32 db48x left 07:34 _jrjsmrtn left 07:35 __jrjsmrtn__ joined 07:39 lizmat left 07:43 db48x joined 07:51 aborazmeh left 07:53 sena_kun left, lizmat joined 07:56 wingfold left 07:57 wingfold joined 07:59 sena_kun joined 08:05 jmerelo joined 08:06 LizBot joined 08:07 Manifest0 left 08:09 Manifest0 joined 08:23 Sgeo left 08:28 abraxxa1 left 08:32 Black_Ribbon left 08:34 abraxxa joined 08:38 aborazmeh joined, aborazmeh left, aborazmeh joined 08:39 pecastro joined 08:45 mniip left 08:51 aborazmeh left 09:28 frost-lab joined
patrickb o/ 09:36
Assuming RakuAST would already be a thing. If I'd try to create a binding generator for some API that provides machine consumable API descriptions, would I better generate plain text source files with loads of NativeCall stubs in it, or better directly generate bytecode via RakuAST? What would be the tradeoffs of the two approaches? 09:40
09:40 mniip joined
patrickb I guess the RakuAST approach would be more difficult to distribute, as I'd either have to distribute only the bytecode, or have the user run the generator on installation. 09:41
09:54 ukine left
lizmat I would go for the source file with stubs in it 09:54
EVAL is still the most versatile parser :-)
09:55 domidumont joined
lizmat another approach could be a DSL, but why would you ? 09:55
El_Che wouldn't ast be more portable than nativecall? 09:56
leont would prefer AST too, but RakuAST hasn't been merged yet so that means waiting 09:58
lizmat having worked a little bit with RakuAST for a printf implementation 09:59
I know that people might underestimate a. the ease of working with RakuAST, and b. the readability
El_Che so it's easier to work with than expected, but less readable? 10:00
(trying to parse your statement :) )
lizmat github.com/rakudo/rakudo/blob/raku...r.pm6#L690 10:04
El_Che leont an example of creating AST's in code 10:05
I've put the equivalent Raku code above every time, because *I* needed that to be able to easily read the code 10:06
10:07 rindolf joined
patrickb Hm. So RakuAST is good for live code generation (e.g. generating a Route handler in Cro, database code some SQL slang / ORM and similar), but no good fit if the result is to be persisted and / or distributed as in an API wrapper. 10:11
Or do I miss a good reason to use RakuAST for something like that?
lizmat I would say that is a correct assessment 10:12
Raku code or a DSL would be better for that, I'd say
and the Raku code could be a pre-compiled (generated) module ? 10:13
10:13 samcv left
patrickb Then my intuition was right. Thanks for giving opinions everyone! 10:13
10:13 samcv joined
lizmat basically, any situation where you would now create Raku source code to be used directly in an EVAL 10:14
will benefit from RakuAST
10:14 aluaces left
lizmat anything else, I would say, is not a good fit 10:15
leont has code that generates a regex, that should be made easier too
lizmat yes, it would, because now you're basically using EVAL for that (under the hood but still ) 10:16
leont Regex concatenation is a nasty thing to do 10:18
@elements.reduce({ /$^a$^b/ }) 10:19
lizmat github.com/rakudo/rakudo/blob/mast...POLATE.pm6 # read and shudder :-)
10:42 frost-lab left 11:06 wamba left 11:12 kurahaupo_ left 11:17 kurahaupo joined 11:44 patrickb left 11:46 DiffieHellman left 11:47 DiffieHellman joined 11:54 wingfold left 11:55 wingfold joined 11:57 MasterDuke left 11:59 tejr left, natrys joined 12:00 tejr joined 12:02 domidumont left, aluaces joined 12:03 ufobat left 12:36 jmerelo left
Xliff \o 12:51
Does raku have a built in clamp-like function?
leont had wanted to port Crypt::Passphrase to Raku, but he may have to adopt Crypt::Argon2 and Crypt::Bcrypt for that to be viable 12:54
12:55 titsuki joined
lizmat wonders what clamp-like is 13:08
El_Che developer.mozilla.org/en-US/docs/W...SS/clamp() 13:11
soen languages take a compare function as a parameter
lizmat looks like an easy ecosystem function to make 13:13
13:18 Nornie28 joined 13:19 Nornie28 left 13:24 LizBot left 13:25 wingfold left
Xliff lizmat: sub clamp($a, Range() $r) { max( $r.min, max($a, $r.max) ) 13:33
m: sub clamp($a, Range() $r) { max( $r.min, max($a, $r.max) ); 10.&clamp(0..5).say
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3, max($a, $r.max) ); 10.&clamp(0..5).say7⏏5<EOL>
expecting any of:
statement end
statement modifier
statement modifier loo…
Xliff m: sub clamp ($a, Range() $r) { max( $r.min, max($a, $r.max) ); 10.&clamp(0..5).say 13:34
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3, max($a, $r.max) ); 10.&clamp(0..5).say7⏏5<EOL>
expecting any of:
statement end
statement modifier
statement modifier loo…
Xliff m: sub clamp ($a, Range() $r) { max( $r.min, max($a, $r.max) }; 10.&clamp(0..5).say
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3ge() $r) { max( $r.min, max($a, $r.max) 7⏏5}; 10.&clamp(0..5).say
Xliff m: sub clamp ($a, Range() $r) { max( $r.min, max($a, $r.max) ) }; 10.&clamp(0..5).say
camelia 10
Xliff Huh.
Glad I checked that.
That second max should be a min. 13:35
m: sub clamp ($a, Range() $r) { max( $r.min, min($a, $r.max) ) }; 10.&clamp(0..5).say
camelia 5
14:05 wingfold joined 14:07 domidumont joined 14:10 wingfold left 14:23 guifa2 joined 14:24 codesect` left, codesections left 14:25 codesections joined 14:31 rindolf left 14:43 guifa2 left 14:46 guifa2 joined 14:48 guifa2 left 14:50 guifa2 joined 14:52 guifa2 left 14:54 parabolize joined, guifa2 joined 14:55 guifa2 left, telex left 14:56 telex joined 15:09 natrys left 15:14 Sgeo joined 16:01 jmerelo joined 16:02 wingfold joined 16:07 domidumont left 16:22 domidumont joined 16:34 stoned75 left 16:36 stoned75 joined
moritz_ m: sub clamp($a, Range() $r) { $.min max ($r min $r.mx ) }; say clamp -4, 0..5 16:56
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable $.min used where no 'self' is available
at <tmp>:1
------> 3sub clamp($a, Range() $r) { $.min7⏏5 max ($r min $r.mx ) }; say clamp -4, 0.
expecting any of:
term
moritz_ m: sub clamp($a, Range() $r) { $r.min max ($r min $r.mx ) }; say clamp -4, 0..5
camelia No such method 'mx' for invocant of type 'Range'. Did you mean any of
these: 'max', 'Mix'?
in sub clamp at <tmp> line 1
in block <unit> at <tmp> line 1
moritz_ m: sub clamp($a, Range() $r) { $r.min max ($r min $r.max ) }; say clamp -4, 0..5
camelia 0..5
moritz_ not quite what I expected
17:06 lizmat left
gfldex m: sub clamp($min is raw , $target is raw, $max is raw) { ($min max $target) min $max }; say clamp 0, -5, 10; say clamp 0, 5, 10; say clamp 0, 15, 10; 17:13
camelia 0
5
10
gfldex I believe Raku does not have a clamp function because we got properly working min/max operators. 17:14
17:16 lizmat joined 17:18 domidumont left
codesections gfldex: I thought that there was general agreement-in-principle to adding clamp to CORE if someone is willing to do the implementation? github.com/Raku/problem-solving/is...-475871264 17:21
17:24 LizBot joined 17:50 jmerelo left 17:51 wamba joined 17:56 Xliff left 18:02 kurahaupo left, kurahaupo joined 18:04 mniip left, db48x left, kvw_5 left, b2gills left, dogbert17 left, aindilis left, m_athias left, cooper left, webstrand left, Ekho left 18:07 mniip joined, db48x joined, kvw_5 joined, b2gills joined, dogbert17 joined, aindilis joined, m_athias joined, cooper joined, webstrand joined 18:08 LizBot left, LizBot joined 18:10 Ekho joined
kurahaupo gfldex: is inserting parentheses into $min max $target max $min actually required? What's the associativity of min & max? 18:11
*what're 18:12
[Coke] m: say 3 min 5 max 10 18:21
camelia 5===SORRY!5=== Error while compiling <tmp>
Only identical operators may be list associative; since 'min' and 'max' differ, they are non-associative and you need to clarify with parentheses
at <tmp>:1
------> 3say 3 min 57⏏5 max 10
[Coke] ^^ 18:22
m: say 3 min 5 min 10
camelia 3
[Coke] m: say [min](3,5,10) # aka
camelia 3
codesections isn't `[min](3,5,10)` just `min(3,5,10)` with extra typing? 18:34
raydiak seems weird. that precedence level in the docs is listed as "|| ^^ // min max". but || and // can be freely mixed, and act as if they were left associative instead of list associative. I don't understand why that entire precedence level shouldn't act the same 18:36
gfldex m: say &[max].WHAT, &max.WHAT; 18:38
camelia (Sub+{is-pure}+{Precedence})(Sub+{is-pure})
gfldex codesections: ^^^ yes, right now they are quite close. But I would assume the compiler to cheat with operators but not with subs. 18:39
codesections gfldex: why's that? If we stick to the idea that "operators are just subroutines with funny names", then I'd expect the compiler to cheat equally with both 18:42
18:44 dataangel joined
gfldex For user defined operators that is surly true. But we want our nice language to become a nice fast language. If your name is Rakudo, cheat away! 18:44
codesections well, sure. But surely that applies to built-in subs too, right? 18:45
gfldex .wrap 18:50
codesections hmm, I was thinking about raydiak's question and wondered if the docs were right about the assoc. of ||, ^^, and //. Is there a way to introspect the associativity of an operator? I expected to find a method on the Method, but I don't see one 18:51
gfldex Well, to some degree that is true. But I see subs as more dynamicly then operators. Raku is a lot less dynamic that it looks on the surface. And we need it to be to get the speed we want.
codesections (I know I can just check the source; just curious, though )
gfldex Sub+{is-pure}+{Precedence} there must be a role somewhere 18:52
m: say &[min].prec; 18:53
camelia {assoc => list, prec => k=}
gfldex :D
codesections: see: src/core.c/traits.pm6
codesections m: say &infix:<||>.prec 18:54
camelia {assoc => list, prec => k=, thunky => .t}
lizmat note that on the rakuast branch, all that knowledge lives in OperatorProperties.pm6
gfldex That made me chuckle because I used introspection to find more introspection. :)
codesections :)
19:06 natrys joined 19:26 mattfly joined 19:31 stux|RC-only left, titsuki left 19:34 stux|RC-only joined 19:40 stux|RC-only left 19:42 stux|RC-only joined 19:44 dylanwh left 19:53 brtastic joined
brtastic Cro::Websocket tests are failing for me, version 0.8.4, should I be concerned or force the installation? 19:54
19:57 stux|RC-only left 20:02 Anton joined
Anton Hi! I asked the following question on the raku Discord channel, but I did not get sufficient feedback. I hope whoever sees this question again won't be too annoyed... 20:04
 I am working on a package for parsing numeric word forms, e.g. say from-numeric-word-form('one thousand and twenty three') that should give 1023. Here is the repository of the package: github.com/antononcube/Raku-Lingua...cWordForms . At this point I have not added that many languages (only nine) but maybe that is enough to submit 20:06
that package to modules.raku.org/ ?
Also, as I have mentioned in the README.md, instead of submitting a new package, maybe I should request to be merged with Lingua::Number ?
codesections Anton: I don't think there's any minimum size for a module to be worth submitting to the ecosystem (even informally/as a common practice) 20:11
El_Che Anton: discuss the merge with the author, is (s)he wants to merge or not, if the api is similar
Anton: but you can submit modules, just be clear in your documentation what the state is
lizmat also, some modules on the ecosystem just export a single sub 20:12
eigenstates being such an example
Anton lizmat So, your advice is to make a module with just one function? (I am looking at eigenstates right now.) 20:13
lizmat well, not in general: if functions share common idea, they could be in one module 20:14
e.g. Array::Sorted::Util
Anton codesections El_Che Thanks, I will make a submission soon. 20:15
El_Che Anton++ 20:16
codesections Anton: also, if you're interested in the area/colaborating with others, you might want to talk with guifa (IRC nick)
Anton @lizmat Ok, I think I have a reasonable set of three related functions: to-numeric-word-form(), from-numeric-word-form(), and translate-numeric-word-form() .
lizmat there you go!
codesections (aka alabamenhu (github)/ mateu (module directory)) 20:17
Anton My "problem" is that Lingua::Number has a version of to-numeric-word-form(), but I think it is buggy, and I think that it is Lingua::Number is under-document. 20:18
lizmat check it out with guifa2
I'm quite sure they're willing to work things out and make things better
Anton My "problem" is that Lingua::Number has a version of to-numeric-word-form(), but I think it is buggy, and I think that Lingua::Number is under-document.
codesections (Yeah, I mention guifa because they have a number of modules in a somewhat similar vein: modules.raku.org/search/?q=intl)
Anton codesections Yes, I think that too. I looked/browsed those packages at some point. 20:19
codesections Anton++ 20:20
20:21 stux|RC-only joined
Anton codesections El_Che lizmat Thanks for the advice on Lingua::NumericWordForms! 20:22
lizmat ++Anton 20:23
Anton I have another set of questions related to resource ingestion. (1) Are resource files ingested during installation and/or package load? (2) Does the design of Raku envision the ingestion of large resource files? Say, a few CSV files with 100K rows each. (3) I think it is better to use the Singleton Design Pattern to ingest larger resource files. Am 20:26
I correct?
20:29 Anton left
lizmat the %RESOURCES hash just points to the resources... 20:29
20:29 Anton joined
lizmat it's up to the developer when to use them 20:29
20:29 Anton left 20:30 Anton3 joined
Anton3 Here is a repository that exemplifies my questions above: github.com/antononcube/Raku-DSL-En...eographics . The goal of that repository is to provide parser-interpreters of geographic locations that can be used in other grammars or roles. So, the repository has a few CSV files that map geographical names and adjective to 20:30
corresponding IDs.
20:31 ecocode left
Anton3 @lizmat "it's up to the developer when to use them" -- Ok. This means -- I think -- that using Singleton is the right approach. 20:31
lizmat [22:29:23] <lizmat>the %RESOURCES hash just points to the resources...
I guess you missed that
20:34 ecocode joined
Anton3 @lizmat " %RESOURCES hash just points to the resources" -- I understand that. My questions are not clear. I will try to clarify... 20:35
If I have this code in "main" module file: 20:40
use v6;
 use DSL::Shared::Roles::English::PipelineCommand;
 use DSL::Shared::Utilities::FuzzyMatching;
 #-----------------------------------------------------------
 my $fileName = %?RESOURCES<CountryAdjectiveToName.csv>;
 my Str @adjNamPairs = $fileName.lines;
 my Str %countryAdjectiveToName{Str} = @adjNamPairs.map({ $_.lc.split(',') }).flat;
 my Set $knownCountryAdjectives = Set(%countryAdjectiveToName);
 my Set $knownCountryAdjectiveWords = Set(%countryAdjectiveToName.keys.map({ $_.split(/h+/) }).flat);
I assume that the resource files content is read only once -- at module installation and/or load. 20:41
lizmat if you code it like that, it will be read every time the module is loaded 20:42
20:43 MasterDuke joined
Anton3 Unfortunately, with the approach in the code above I did not figure out how to use/access the sets $knownCountryAdjectives  and $knownCountryAdjectiveWords in the other files of the project. So, I implemented the Singleton pattern instead, which will guarantee that the resource data is read/ingested only once per session. 20:44
@lizmat "if you code it like that, it will be read every time the module is loaded" -- Ok, thanks.
lizmat I wonder if it wouldn't make sense to actually generate Raku code from the csv 20:45
20:46 stux|RC-only left
lizmat put that in a submodule, and use that: then it *would* be precompiled 20:46
MasterDuke .tell Xliff what about `for ^5 { once say "first"; .say }`? i.e., `once` instead of `FIRST` 20:47
20:48 stux|RC-only joined, natrys left
Anton3 @lizmat Yes, I agree I tried something like that. I simply generate the code for a very large role. Here is (much smaller) example: github.com/antononcube/Raku-DSL-En...es.rakumod 20:48
lizmat yup, looks like 20:50
Anton3 And yes I have seen examples of generating rules and tokens in role objects.
20:50 unicodable6 left
lizmat fwiw , I always also generate some comments to indicate how the code was generated, when and which parts shouldn't be touched as they will be overwritten the next time you generate 20:50
20:50 tellable6 joined 20:51 evalable6 joined
Anton3 @lizmat I completely agree. I simple abandoned that approach, but I kept that file in the repository as an example. 20:51
20:51 brtastic left, greppable6 left, abraxxa left, releasable6 left, committable6 joined 20:52 shareable6 joined
lizmat well, parts of the Raku core are generated, and parts of some of my modules are generated that way 20:52
20:52 sourceable6 joined, asymptotically left 20:53 bisectable6 joined
Anton3 The thing is that very familiar with Mathematica, so I generate the code using Mathematica packages. For example, this one: github.com/antononcube/Conversatio...neration.m . Then my Mathematica notebook describe the process for the Raku code generation. 20:53
20:53 statisfiable6 left
MasterDuke .tell Xliff what about `for ^5 { once say "first"; .say }`? i.e., `once` instead of `FIRST` 20:53
tellable6 MasterDuke, I'll pass your message to Xliff
20:54 statisfiable6 joined 20:55 unicodable6 joined
Anton3 @lizmat But closer to your point probably this example of Raku tests generated with Mathematica: github.com/antononcube/Raku-Lingua...-English.t 20:55
20:55 stux|RC-only left
Anton3 @lizmat Thank you again for your feedback! 20:55
lizmat you're welcome! 20:56
20:56 tellable6 left 20:57 releasable6 joined 20:58 Anton3 left 20:59 stux|RC-only joined
[Coke] [min]() and min() work out the same, but in general you could have a sub that only takes two args, so the foo(1,2,3) form isn't always guaranteed to work 21:03
21:04 Black_Ribbon joined
MasterDuke the infix form is a lot faster (at least used to be a while ago) 21:05
21:05 sourceable6 left, benchable6 left, sourceable6 joined, bloatable6 left 21:06 HarmtH left 21:07 nativecallable6 joined, tellable6 joined, bloatable6 joined, greppable6 joined 21:10 stux|RC-only left 21:16 mattfly left
codesections [Coke]: fair point 21:16
21:18 stux|RC-only joined 21:24 stoned75 left 21:32 aborazmeh joined 21:49 evalable6 left, shareable6 left, statisfiable6 left, bisectable6 left, unicodable6 left, committable6 left, sourceable6 left, bloatable6 left, tellable6 left, releasable6 left, coverable6 left, greppable6 left, nativecallable6 left 21:51 unicodable6 joined, sourceable6 joined 21:52 notable6 joined, greppable6 joined, releasable6 joined, statisfiable6 joined, committable6 joined 21:53 evalable6 joined, tellable6 joined 22:32 rindolf joined 22:36 Kaiepi left 22:40 aborazmeh left 23:11 pecastro left 23:15 Kaiepi joined 23:24 cpage joined 23:29 cpage left 23:32 cpage joined