🦋 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.
00:06 dogbert17 left, dogbert17 joined 00:19 dogbert11 joined, dogbert11 left 00:20 dogbert11 joined 00:22 dogbert17 left
guifa2 codesections: ha. Sounds like someone who's fielded one too many requests to make their thing localizable 01:10
01:22 evalable6 left, linkable6 left 01:23 evalable6 joined 01:24 linkable6 joined 01:27 pecastro left 01:41 sftp joined
codesections guifa2: oh interesting – that's not how I read it at all. I read it as someone making a point about the importance of internationalization (even when they aren't able to do it at the moment in a solo project). A lot of developers (ime) would put internationalization in the nice-to-have extra/feature request category; I read calling it out as a known bug as recognizing that it's more important than "a missing feature" 01:43
01:43 gnufr33dom joined 01:45 asymptotically left, asymptotically joined 01:50 Garbanzo joined, leont left 01:53 Black_Ribbon joined 02:02 kvw_5 joined 02:05 kvw_5_ left 02:10 Black_Ribbon left 02:14 Black_Ribbon joined 02:17 mowcat joined 02:50 xheimlich joined
xheimlich I have a little pet project I'd like to try to write in Raku. So I can learn some Raku. 02:51
It's some fairly basic text wrangling and talking to a sqlite database. I guess it could be done in bash and sed for props too, but.
codesections Yeah, that sounds like a good use case for Raku 02:52
xheimlich Anyway, I'm going to be looking at (long), book-length plain text, separating by [paragraph] and marking some [special terms] with brackets and parentheses. 02:53
(Parentheses) are definitions, brackets are references to definitions.
codesections I haven't personally used Raku and sqlite together, but I can't think of any barrier. And Raku definitely excels at text wrangling
xheimlich Then after some stuff I've really worked out already as sqlite views, we have a directed graph of paragraphs. and then I do something like solve for a minimum spanning tree to put the paragraphs in order. 02:54
In this way a technical book could be compiled. 02:55
02:55 aborazmeh left
xheimlich There was an advent of perl blog post I saw that worked out something not too unlike this with regexes and then said "screw it, let's use Perl Grammars". 02:56
But it was a matter of extracting all parts of a little structured log thing. Whereas I need (1) the (definitions), (2) the [references] and (3) the cleaned-up text. as a list/array/something of paragraphs. 02:57
I'm not good with regexes beyond using them to ctrl-F stuff. I can build them by trial and error on regexr.com sometimes or ask around for help. 02:58
anyway, what should I learn, regexes or grammars?
codesections Well, it's not really that much of an either-or 02:59
summerisle well, Raku regexps can be used in grammars
i think the logical order would be to understand the raku regexp syntax and semantics and then grammars
all of it is quite simple
codesections grammars are basically more structured ways to write regexes
02:59 kvw_5_ joined
codesections (a Grammar is a bit like a Class -- and regexes are a bit like the methods in that class) 03:00
xheimlich maybe to be clearer, I kind of understand how to build regexes that say "match" or "no match". like in grep.
codesections (in that they're name spaced and operate there etc) 03:01
xheimlich I've never learned to capture content with regexes. In Python, where I make a living gluing together ML type libraries for applications.
summerisle if you're doing ML stuff it can be invaluable for cleaning and reorganizing data 03:02
i was building a single bigquery database of nearly every obtainable credential leak (currently at around 3bn rows, haven't worked on it in a while) and P5 was just a killer app for that. Raku would be similar. 03:03
codesections (also, Raku regexes simplify capturing a lot, imo)
03:03 kvw_5 left
xheimlich summerisle: there's just so much advanced tooling for that. magically guessing what the hell a txt file that might be tab-delimited or semicolon-delimited with values in quotes and spanish-style comma-separated decimals. 03:03
summerisle you have to know something about your input data 03:04
xheimlich anyway, this is a pet project, and I really wanted to learn some new programming language.
summerisle Raku is pretty great. I've been hooked on it.
building a replacement for beets (music manager) with it
xheimlich I managed to work out much of it using a sql model with foreign keys and a couple of named views.
03:10 mowcat left
summerisle one of my favorite things so far with raku has been NativeCall. Makes it really easy to do RAD with C stuff, or to prototype over C, etc... 03:15
I'd like to build an interactive shell with raku interpolation a la POSH
xheimlich there's a lot of sqlite libraries for perl! what to use? 03:18
summerisle for Raku? or are you using Perl? 03:19
xheimlich I don't know why I said Perl. 03:20
Python has sqlite3 utilities in the stdlib, but the good library is this: github.com/nackjicholson/aiosql 03:21
it kind of defines a paper-thin DSL that's sql with some special syntax that allows it to build Python functions. 03:22
03:40 sortiz left 03:50 mowcat joined 04:38 frej00 joined 04:44 vike left 05:11 vike joined
guifa2 xheimlich: have you looked at Slang::SQL? 05:12
that's one extreme of Raku's philosophy of working with something like SQL. The other extreme is using Red 05:13
see fco.github.io/Red/
05:29 mowcat left
summerisle is there any good documentation on slangs out there? 05:39
05:44 mowcat joined
guifa2 summerisle: not too much yet. There are a few examples you can see in the wild, but they're a bit more complex and not quite as polished up as other things are ATM 05:45
I'm probably going to do an article at some point on how to create a custom quoting language (similar to Q) so I can help with that but I haven't done a lot of really crazy stuff with it 05:47
(theoretically, though, you could make it so you say "use Inline::JavaScript" and then everything would use JavaScript-y syntax until a closing bracket
06:10 guifa2 left, guifa2 joined 06:37 rindolf joined, frej00 left 06:48 mowcat left 07:03 defaultxr left 07:05 defaultxr joined 07:24 aborazmeh joined 07:28 aborazmeh_ joined 07:29 aborazmeh left 07:30 parabolize left 07:31 DiffieHellman left 07:40 vike left 07:42 japhb left 07:48 aborazmeh joined 07:49 aborazmeh_ left
guifa2 codesections: take a look at this beauty. After all the work to get the plural count and number formatting figured out, formatting UNITS (e.g. "5 meters", "1 km", etc) ends up being this simple 08:13
github.com/alabamenhu/IntlFormatUn...t/Unit.pm6
08:14 vike joined 08:20 aborazmeh left 08:31 synthmeat left, finsternis left, aborazmeh joined 08:40 synthmeat joined, finsternis joined 08:47 JJAtria[m] left, krako[m] left, ChoppedBacon left, a3f left, mightypork left 08:49 tomaw left, aborazmeh left, aindilis left, orinthe left, maggotbrain left, perigrin left, sjn left 08:50 rypervenche left, MitarashiDango[m left, kiti_nomad[m] left, Sir_Ragna left, finsternis left, dogbert11 left, El_Che left, Maylay left, gordonfish left, mark[m]4 left, pwr22 left, JJAtria[m] joined, krako[m] joined, ChoppedBacon joined, a3f joined, mightypork joined, sftp left 08:52 finsternis joined, dogbert11 joined, El_Che joined, Maylay joined, gordonfish joined, Ekho joined, freezing joined, m_athias2 joined, dylanwh joined, mrsolo joined, dustinm` joined, rba joined, mst joined, klapperl joined, BarrOff[m] left, aborazmeh joined, aindilis joined, orinthe joined, maggotbrain joined, perigrin joined, sjn joined, _________ joined, webstrand joined 08:53 krako[m] left, AlexDaniel` left, stux|RC-only joined, JJAtria[m] left, Ekho left, gordonfish left, sftp joined, unclechu left 08:54 CIAvash left, Tirifto[m] left, l-as left 08:56 ThaEwat left, buffet joined, samebchase joined, pel joined, cj joined, tomaw joined, APic joined 09:01 rypervenche joined, Sir_Ragna joined, tinita joined, tonyo joined, tadzik joined, UukGoblin joined 09:03 mniip joined 09:06 aborazmeh left 09:07 Ekho joined 09:24 BarrOff[m] joined, AlexDaniel` joined, CIAvash joined, mark[m]4 joined 09:26 MitarashiDango[m joined 09:32 JJAtria[m] joined 09:37 kiti_nomad[m] joined, Tirifto[m] joined 09:42 MitarashiDango[m left, Tirifto[m] left, JJAtria[m] left, CIAvash left 09:43 mark[m]4 left, kiti_nomad[m] left, BarrOff[m] left, AlexDaniel` left 09:50 aluaces_ joined, aluaces left 09:54 gnufr33dom left 09:56 Sgeo left 10:00 Sgeo joined 10:15 Discipulus joined 10:19 pwr22 joined 10:25 krako[m] joined 10:28 ThaEwat joined 10:32 unclechu joined, l-as joined 10:33 aborazmeh joined 10:36 aborazmeh left, Tirifto[m] joined, kiti_nomad[m] joined 10:41 MitarashiDango[m joined, JJAtria[m] joined 10:45 CIAvash joined 10:47 mark[m]4 joined 10:54 BarrOff[m] joined, AlexDaniel` joined 10:59 DiffieHellman joined 11:01 Sgeo left 11:03 aindilis left 11:09 Black_Ribbon left 11:11 wamba joined 11:18 aluaces_ is now known as aluaces 11:25 aluaces is now known as aluaces_ 11:26 pecastro joined 11:35 raiph joined 11:37 raiph left 11:38 raiph joined 11:46 nevore joined
nevore p6: for ^10 { srand 1; (^100).pick.say } 11:48
evalable6 62
65
65
65
65
65
65
65
65
65
11:51 aborazmeh joined
nevore but on windows 10, this prints "25 25 25 25 25 25 25 25 25 25", all values are the same. 11:51
different platforms have different behaviors, is this a bug? 11:53
El_Che "Note that srand is called with a platform dependent value when a Raku program is started." 11:58
nevore well, it makes some sense. 12:03
El_Che you're feeding the pseudo random generator 12:07
maybe you want rand?
12:09 sortiz joined
nevore No, i just checked irc log and found the problem. Then I tested it on windows which worked as expected. 12:12
12:18 stoned75 left 12:19 leont joined
El_Che :) 12:23
12:28 Doc_Holliwood joined
Doc_Holliwood weekly: Globbing depends on the Compiler www.perlmonks.org/?node_id=11128255 12:29
notable6 Doc_Holliwood, Noted! (weekly)
tellable6 2021-01-10T16:03:22Z #raku <Xliff> Doc_Holliwood: ^^ Looks like that's a no.
2021-01-10T16:03:51Z #raku <Xliff> Doc_Holliwood: re: your gather/introspect question
sortiz m: for ^5 {srand 1; say gather { for ^2 { take 100.rand.floor }} } 12:34
evalable6 (92 32)
(78 84)
(78 84)
(78 84)
(78 84)
sortiz nevore: Indeed smells like a bug somewhere. 12:36
12:41 aborazmeh left 12:42 aborazmeh joined 12:47 aborazmeh left, aluaces_ is now known as aluaces 12:48 aborazmeh joined 13:02 monkey__ joined 13:04 Doc_Holliwood left 13:06 sortiz left 13:09 sortiz joined 13:10 aborazmeh left
El_Che releasable6: status 13:11
releasable6 El_Che, Next release in ≈7 days and ≈5 hours. 2 blockers. 22 out of 128 commits logged
El_Che, Details: gist.github.com/ba7e4170a6bb970ad3...fa936ce516
13:11 aborazmeh joined
Discipulus what is Doc_Holliwood? 13:11
13:11 raiph left 13:13 wamba left
Discipulus sortiz: I read and appreciated your post, but I still wonder where glob expansions happens 13:13
what really is "the startup code injected by the build environment"? 13:14
sortiz The code that calls "main" at the C level. 13:15
Discipulus is another tiny layer where code from command line pass before reaching perl? or what? 13:17
oh mìrale! eres del DF?!? :) 13:18
sortiz Yes, almost any language compiler or interpreter is written in C, so got its arguments from the environment in a "main" function, 13:19
Si, completamente chilango. 13:20
13:20 aborazmeh left
Discipulus que bueno! estuvo varias veces donde ti 13:21
so you found raku built with mingw expands because this "C level" expands the glob before passing into main, right? 13:22
sortiz In PÔSIX systems the argument parsing is done by the shell command interpreter, and seems that mingw attempts to mimic that. 13:23
Discipulus another question rise: if so, then i could build perl using mingw and have the same effect?
13:24 aborazmeh joined
Discipulus because i tried to build my own perl using mingw (first time I do something similar) and I got no exapnsion 13:24
is my supposition totally wrong, or maybe something feasible? 13:26
sortiz If so, sure. But the details are still not clear and now I'm hunting another problem.
Discipulus :) ok no problem.. hasta horita pues 13:27
sortiz Lo voy a investigar, cuenta con ello. :-)
m: use nqp; for ^3 { srand 1; say gather { take nqp::floor_n(nqp::rand_n(100e0)) } }; 13:30
evalable6 (52)
(78)
(78)
sortiz m: use nqp; for ^3 { srand 1; say nqp::floor_n(nqp::rand_n(100e0)) }; 13:31
evalable6 30
30
30
13:31 El_Che left
sortiz Why gather/take perturbs the random seed? 13:33
13:35 Doc_Holliwood joined, aluaces is now known as aluaces_ 13:38 El_Che joined 13:41 kst left 13:45 monkey__ left 13:53 El_Che left 13:57 nevore left 13:58 eseyman joined
sortiz Discipulus: BTW, If all you need is the expansion in your Windows code, in perl you can use File::Glob, that emulates the standard POSIX glob(3) 13:58
13:59 monkey__ joined 14:01 monkey__ left 14:24 tomaw left 14:25 tomaw joined 14:39 wamba joined 14:40 wamba1 joined 14:44 wamba left 14:47 wamba1 left 14:48 wamba joined 14:50 monkey__ joined 14:55 aborazmeh left
Discipulus sortiz: thanks but no. I want to create a frankensteinwin32perl :) 14:56
14:57 wamba1 joined 14:59 wamba left 15:10 gordonfish joined 15:16 aborazmeh joined 15:22 El_Che joined
sortiz m: for ^3 { srand 0; say (rand,rand)[1]}; 15:24
evalable6 0.6170728045443533
0.6170728045443533
0.6170728045443533
sortiz m: for ^3 { srand 0; say (rand for ^2)[1]};
evalable6 0.3603211140064947
0.6170728045443533
0.6170728045443533
15:49 Discipulus left 15:50 dumbanddumber123 joined 15:52 dumbanddumber123 left 16:02 Discipulus joined 16:04 parabolize joined 16:05 aborazmeh left 16:06 aborazmeh joined 16:11 aborazmeh left 16:14 aborazmeh joined 16:21 aborazmeh left 16:22 aborazmeh joined 16:23 monkey__ left 16:37 gnufr33dom joined 16:48 aborazmeh left 16:49 aborazmeh joined
sortiz m: for ^3 { srand 0; say (rand.sink, rand)[1]}; # as for, sink disturbs the sequence 16:50
evalable6 0.46495824287750764
0.6170728045443533
0.6170728045443533
sortiz m: for ^3 { ENTER srand 0; say (rand.sink, rand)[1]}; # fixed 16:51
evalable6 0.6170728045443533
0.6170728045443533
0.6170728045443533
16:54 aborazmeh left 16:55 aborazmeh joined 17:02 aborazmeh left 17:03 aborazmeh joined 17:05 leont left 17:08 aborazmeh left 17:09 aborazmeh joined 17:16 aborazmeh left 17:17 aborazmeh joined 17:24 domidumont joined 17:47 aborazmeh left 17:52 aborazmeh joined 17:53 sortiz left 18:17 CJam joined 18:18 CJam left 18:28 aborazmeh left 18:38 aindilis joined 18:56 ifim joined
codesections m: sub f(Int $i) { dd $i }; f(True) 19:08
evalable6 Bool::True
codesections is ^^^^ an indication that Raku uses smartmatch semantics more than it "should" for typechecking? 19:09
or, wait, it just is the case that Bools inherit from Ints, oh 19:10
I guess that's a legacy of them being derived from C-style enmums. But it's not great, imo 19:11
m: sub f(Int $i) { dd $i }; f(False) 19:12
evalable6 Bool::False
guifa2 Yeah. It's actually rather nice when doing math TBH
m: say 8 * False + 4 * True
evalable6 4
codesections yeah, I knew that 19:13
but I thought the operators were doing some coercion 19:14
guifa2 Inasmuch as the Enum does it
codesections m: say 7 ~ 'foo' 19:15
evalable6 7foo
codesections that ^^^ doesn't imply anything about the type relationship
19:19 mowcat joined 19:21 El_Che left, sampersand joined
sampersand hi, can `die` be considered pure? 19:21
tellable6 2021-02-03T06:46:50Z #raku <elcaro> sampersand maybe this helps (re: $!private attrs, `bless` and `new`) gist.github.com/0racle/959a94fdb38...a150150dfc
sampersand not particularly tellable6 thanks though 19:22
19:22 El_Che joined
AlexDaniel` so where's camelia? 19:23
guifa2 sampersand: that's from elcaro from a few weeks ago haha
AlexDaniel` I think I asked that before but I'm not sure if I received a clear answer
sampersand wdym guifa2
codesections So, what falls out of that is that many CLI &MAIN functions I've written should have an IntStr type constraint instead of an Int one
guifa2 sampersand: Tellable is a bot. If someone's not online, i can type ".tell $name $message", and when tellable sees them active (sending a message to the channel), it'll relay the message 19:24
sampersand oh funky
guifa2 .tell codesections did you see the format-unit code? (this message will be delivered when codesections says something) 19:25
tellable6 guifa2, I'll pass your message to codesections
codesections oh, I _thought_ there was something different about the replies I was getting from m:
hmm
sampersand i got my answer from the raku discord for the private thing
AlexDaniel` guifa2: the bot is smart enough to know that codesections is right here reading the message, so it doesn't relay needlessly :)
guifa2 Why do we make bots so smart that they mess up what we're trying to do?
lol
AlexDaniel` codesections: yeah, it's an automated fallback in evalable6. It checks if camelia is not online and does its job if it is so 19:26
codesections the question of the modern age
sampersand so back to my other question. can `method cmp(Value $) is pure { die 'Cannot compare Null.' }` be considered pure?
guifa2 .tell tellable6 I need to rewire you, hope you like electroshock therapy
tellable6 guifa2, Thanks for the message
codesections that's nifty AlexDaniel` But brings us back to your question of what happened to her 19:27
AlexDaniel` 🤷
codesections sampersand: I wouldn't think so? I'd consider dying to be a pretty major side effect 19:28
AlexDaniel` if we add fallback for evalable6 too then when it fails we'll also never bother to figure out what happened to it x)
sampersand codesectionsi mean, it always returns the same result: program exit lol
AlexDaniel` there was this bot, undersightable6, that used to check the status of many important services 19:29
codesections that's ... not how backups are supposed to work :D
AlexDaniel` well, it was a useful service that basically just said “hey, you have a problem somewhere” 19:30
too bad it… died itself…
sampersand So far ive been using `use MONKEY-SEE-NO-EVAL; EVAL qx<cat classes.raku>;` to import local files '=D but i figured i might as well learn how modules work. So i tried docs.raku.org/language/modules and it's just a lot of information. is there somewhere i can find a simple example of a thre eor four file project with importing things?
guifa2 sampersand: AFAICT, you can MARK it as is pure 19:31
but the dying will cause the compiler to do a big oopsie, and leave it for runtime 19:32
19:32 wamba1 left
sampersand is there a way to cache compiled programs so raku doesnt take a good seocnd and a half just to parse my file 19:33
guifa2 m: sub foo is pure { say "pure"; die }; BEGIN say "precompile"; CHECK say "postcompile"; INIT say "preexecute"; END say "postexecute"; say foo();
evalable6 (exit code 1) precompile
Died
in sub foo at /tmp/kzNc7_Dn9U line 1
in block <unit> at /tmp/kzNc7_Dn9U line 1

postcompile
pure
preexecute
pure
postexecute
guifa2 sampersand: the simplest way to use a module is have a folder called "lib" (or whatever you want) in the directory as your script. 19:35
Make a file called "my-awesome-module.rakumod" inside of the folder
19:35 aborazmeh joined
guifa2 start the file off with "unit module CoolModuleName;" and mark things you want to have imported in with "is export" (e.g. "sub foo ($a, $b) is export { … }") 19:36
in your main script, "use lib 'lib' " (or whatever you called the folder). The symbols should be imported
sampersand do i need to mark methods within classes/roles as export if the class/role is export already
guifa2 no, just mark the class/role 19:37
19:37 ifim left
sampersand and how do i get mof files to import eschother 19:37
rakumod*
codesections sampersand: re: compile times -- Raku modules are always pre-compiled and cached. Raku scripts never are (but you can move the bulk of the logic to a module)
sampersand oh cool ok ill move everythign to modules now
guifa2 you mean circular dependency? You need to have everything in the same file for a circular dependency and use forward declarations. E.g. 19:38
sampersand not circular deps, more like importing different rakumods into eachother
eg i have `/main.raku`, `/lib/classes.raku` and `/lib/parser.raku`. the parser requires classes, and classes requires a single method from parser. I can predeclare the parser method in classes 19:39
codesections (even so, there's still more time devoted to parsing than we'd like -- that's an area where performance still some room for improvement)
sampersand i wish raku was more production rady, it'd be so much fun to use
codesections We're getting really close! 19:40
guifa2 You can do it the same way "use lib ''" and then "use MyAwesomeModule"). But at a certain point you'll want to start using the META6 file so you can stop saying "use lib" all over the place. But that starts adding a bit more complexity
codesections And, I'd argue, are already there in some areas
guifa2 should write a straight forward guide to making modules 19:41
guifa2 adds it to his giant list of things to do
codesections There was an interesting talk at FOSDEM by someone running Raku (and Cro) in production
running a webservice that manages audio processing/encoding for raw music files 19:42
sampersand Like, if you type in `say 0 for ^5000` to the repl twice, you get a segfault
codesections the repl needs some love, absolutely 19:43
guifa2 github.com/alabamenhu/IntlFormatNumber <-- this is a really basic module structure with two rakumod files, it might show off how some things can be arranged in a real world project
sampersand and ctrl+c quits out is so irritating 19:44
I have this: <github.com/sampersand/knight/tree/raku/raku> but im getting `Could not find symbol '&Null' in 'Knight'` when i run main.raku
guifa2 so once you "use lib 'lib' ", you still have to tell it what stuff to import from the library 19:45
sampersand that link has `,pm6` guifa2. is that somethign i should be doing, or is it deprecated or something
guifa2 sampersand: just force of habit. .pm6 and .rakumod are synonymous
but it is deprecated in theory
sampersand ah
codesections yeah, our repl makes me sad. Raku has so much powerful introspection -- our repl should be *amazing*. And it ... isn't 19:46
(yet)
sampersand oh i see, `use Knight::Null`
guifa2 sampersand: actually, just "use Knight"
sampersand oh ok
guifa2 and Knight::Null should be available
sampersand is there any way to combine those two into one line
19:46 aborazmeh_ joined 19:47 gnufr33dom left, aborazmeh left, ifim joined
guifa2 No. The first one says "you can look here for modules". And the second one says "look for this module" 19:48
sampersand hm im nwo getting this: pastebin.com/C9wChQ1K
codesections ( guifa2 I was going to link www.reddit.com/r/rakulang/comments...sing_raku/ in case you hadn't seen it, but then I saw that you'd commented :D ) 19:49
guifa2 try "use classes" instead of "use Knight" (I normally name my module files identically to their code name)
codesections: I even started using .rakutest for some of my modules!
19:50 dataangel joined
codesections \o/ 19:50
sampersand so how would you rename it then guifa2
guifa2 file name = "Knight.rakumod"
sampersand hm `use classes` doesnt work either. i think im breaking something
but i have two kngiht files 19:51
the parser and the classes
codesections though, apparently, that whole part of github is on hold (?) because the person responsible left the company and hasn't been replaced (???)
19:51 sena_kun left
codesections er, wait, no! that's out of date 19:52
github.com/github/linguist/pull/5168
we *do* get code highlighting now! How'd I miss that‽ 19:53
El_Che we don't
guifa2 sampersand: hmm, it seems you named both module files as "unit module Knight". I didn't realize the connection between them at first. You could for instance have the structure be lib/Knight/Classes.rakumod and lib/Knight/Parser.rakumod, and then use lib 'lib', and then use Knight::Classes; to get stuff from class file, etc. That's how I'd sructure it at least
guifa2 loves the interrobang
sampersand ah ok 19:54
lets try that
couldnt i just name the folder `Knight`?
El_Che codesections: I opened rakumod files, not highlightened
19:54 sena_kun joined
sampersand ie not lib 19:54
El_Che the examples in the PR do not highjlight 19:55
guifa2 sampersand, yes absolutely. Then you'd say "use lib 'Knight'; "
sampersand then `unit module Knight::Classes` ? 19:56
kinda reminds me of perl's module system
codesections El_Che: oh, well, the PR has been merged upstream, anyway. So I guess github will get it when they next cut a release?
guifa2 just "unit module Classes;" for the Classes.rakumod file
El_Che codesections: it would be great
sampersand *facepalm* I wasn't using `.rakumod` 19:57
oh and now i have a `.precomp` folder. amazing 19:58
19:59 ifim left
sampersand gotta say, the ability to use functions as generics is super cool 20:01
20:07 loops joined
sampersand how many of you guys used perl before raku 20:07
guifa2 did 20:08
sampersand I tried Raku awhile ago and was totally lost. Then over a three day weekend without wifi, I used `$ perldoc perlintro` and friends to learn Perl. Coming back to Raku, it makes a lot more sense now lol 20:10
El_Che :)
sampersand well, asides from these damned modules. something's not working again lol 20:11
as a quick aside: does raku have somethign like ruby's `alias` ? 20:12
i have a bunch of `method binary:<+>($/) { make $<sym>.Str }` and being able to just alias them would make my code more DRY
20:18 Sgeo joined
tobs sampersand: for subroutines and lexical visibility, this is as easy as `my &alias = &some-sub` but methods need to register with the class. I think it can be done with the meta object protocol, but I'm not aware of it being built in already. 20:19
El_Che my &foo = sub {"foo".say};
sampersand is it just too much effort for what its worth?
El_Che my &bar = &foo
sampersand ok cool 20:20
El_Che however, I think that aliasing is a code smell
sampersand i need it for my action classes
github.com/sampersand/knight/blob/...u#L97-L109 unless you have a better suggestion 20:21
El_Che you can't have a single method/func with a generic name?
of use a role that the class inherit?
sampersand i have no idea if i can, this is my first project in raku
El_Che docs.raku.org/language/objects#Roles 20:23
but you don't have different classes looking at the code
sampersand yeah this wasnt meant to be that major
El_Che a role is useful is each Action class shared some behaviour
s/is/if/ 20:24
sampersand ah
El_Che so you get saner composition instead of inheritence or copy paste 20:25
sampersand is what im doing with the action class _bad_ 20:26
i learned raku literally by trial and error because i had no internet for a week due to a snow storm and decided to learn it
guifa2 ha, productive time!
sampersand right?
El_Che :)
sampersand i couldnt figure out how `new`, `BUILD` and `bless` worked together 20:27
El_Che impressive storm
guifa2 using a role like El_CHe said is jsut a way to make your code cleaner and more expressive. But repeating the method in each class isn't bad per se, just repetitive
sampersand so i eventually made a `_new` method lol
i only have a single action class
(also, updated the link)
<github.com/sampersand/knight/blob/...akumod>
guifa2 I have to get going now, but I can take a look at your stuff later tonight or tomorrow in more detail. But thank you for reminding me I need to write out a module tutorial 20:28
sampersand haha youre welcome!
im in the process of writing comments for everything too 20:29
guifa2 I've been on a module writing spree, so lots of lessons learned
Even looking back at modules I wrote only a year ago, there's so much I could do better
sampersand if your old code is bad that means your learning :)
guifa2 my main module right now is an ungodly number of lines of code 20:30
github.com/alabamenhu/Intl-CLDR
sampersand the heck is cldr
guifa2 Common Language Data Repository 20:31
sampersand ah
guifa2 It powers a bunch of localization-oriented modules. But it's a behemoth
I've rewritten it three times now, but this is finally the keeper I think
codesections sampersand: looking at the code you linked, that looks like the ideal place for Macros. ...which we don't have yet -- but they're *really* close: news.perlfoundation.org/post/grant...st-2020-12 20:32
20:33 ufobat__ joined
sampersand yeah i saw macros and i was like "the heck? what _else_ does this langauge have! " lol 20:33
so how does raku's typing work? eg if i have all my types annotated correctly, will the compiler not do typechecks 20:34
codesections (oh, context for that link is that RakuAST will unlock a powerful new hygienic macro system, which that post doesn't really explain)
hm?
sampersand oops forgot this wasnt discord and i cant paste large chunks of code lol one sec 20:35
guifa2 Right now typechecks are mostly done at runtime, but theoretically typing it will allow the compiler to optimize more
sampersand So let's say we have this: `sub add-square(Int $lhs, Int $rhs, --> Int) { ($lhs + $rhs) ** 2 }`
If I then have `my Int $lhs = ....;    my Int $rhs = ....;    say add-square($lhs, $rhs); `
if i have that, will the `add-square` call check `lhs` and `rhs`'s types? 20:36
i mean, theoretically the `...` should be checked for both `$lhs` and `$rhs` , so when `add-square` is called, the compiler should know theyre both valid 20:37
guifa2 correct. It's just a question of how much things have been optimized. I'm not sure if that one is handled by the main compiler
guifa2 is not a compiler expert 20:38
sampersand ah darn
raku's speed is one of the main things that makes me hesitant to use it
codesections Yeah. I'm not sure of the current run-time behavior (i.e., how much has been optimized/what guifa2 said faster)
sampersand i absolutely love the idea of hte languae though
s/uae/uage/
codesections what type of speed do you have in mind/speed at what task/benchmark? 20:39
sampersand well, recursive fibonacci of 40 for example
or, i mean even simpler: it takes it 1.2 seconds to parse my file
but like i did some comparisons of languages and i did `sub fib(Int $x --> Int) { $x <= 1 ?? $x !! fib($x-1) + fib($x-2) } say fib: 40; ` 20:40
guifa2 if you're using Int, you're using the equivalent of BigInt in many languages 20:41
sampersand it took raku like 77 seconds on my computer, which is just far longer than everything else i tested :(
guifa2 and you'd probably want to use int
sampersand `int` is a thing?
guifa2 but 77 seounds very long
sampersand i thought all types were uppercase
guifa2 int = native
sampersand til
codesections yeah, startup time is a problem (re: parsing). I'm actually working on a workaround there (more details soon) but it's an area that will take some hard work to get fully fixed (though we're improving!) 20:42
sampersand ok, trying it with `int` now
it'll be a good day when i can use raku in production
oh, another thing is that raku will just sometimes hang without telling me why 20:43
codesections re: fib, yeah you're both not using a native type *and* using a Real rather than a float (the way other languages do)
sampersand so `time raku -e'sub fib(int $x --> int){ $x <= 1 ?? $x !! fib($x - 1) + fib($x - 2) } say fib(40)'` ?
oof 20:44
`raku   166.67s user 0.17s system 99% cpu 2:46.97 total` somehow `int` is slower? 20:45
guifa2 that's odd. Only thing I can think of is somewhere along the way something's being boxed/unboxed. WOrking with natives is a little bit finicky 20:46
sampersand in any case, compare to something like perl which is 40s, python is ≈20, and ruby is 4
if raku could get to 40s, i would be thrilled lol 20:47
guifa2 tio.run/##K0gtyjH7/7@4NEkhLTNJIzOv...UgIU@P8fAA 20:48
47
sampersand wonder if my computer's just trash? idk
guifa2 oh no, the original ones all timed out :-)
sampersand lol
jeeze what version of ruby is tio running 0.o 20:50
2.5.5, explains it
tio.run/##KypNqvz/PyU1TSEtM0mjQpOL...QUTAz@/wcA 20:51
20:51 aborazmeh_ left
guifa2 if ruby is pulling it off in 4 seconds, I wonder if it's doing some behind the scenes caching. I wouldn't expect it to outpace the other interpreted languages by that much 20:53
tio.run/##K0gtyjH7/7@4NEkhLTNJwzOv...WMzE4P9/AA 20:54
El_Che guifa2: what'smore effective than cheating on the tests everyone uses in blogs :)
20:54 ifim joined 20:55 ifim left
guifa2 Of course, there's also a lot to be said about speeding up development time too 20:55
Because this is the bestest of the fibbonachi sequences
sampersand oh yeah fibonaccin raku is amazing
something like `0, 1, * + *, ...` i forget exactly 20:56
guifa2 m: my @fib = 0, 1, * + * ... *; say @fib[40]
evalable6 102334155
sampersand oh i was close
yeah, the fact that the `...` operator exists in raku is hilarious and mind blowing at the same time
guifa2 The TIO link above is a technique I use all over the place, btw. State variables are one of those things you never think you really need… until you do and then they're amaaaaaazing 20:57
sampersand oh i didnt see your response there. ruby 3.0 uses JIT
oh yeah that's memoization, that's cheating xd
guifa2 question is, how easy is it to do that in each langauge? :-) 20:58
there's actual a built in trait (though it's experimetnal ATM)
sub foo is cached { … } 20:59
(need to 'use experimental :cached' for it though)
sampersand i mean, in ruby `def fib(n, m={ 0 => 0, 1 => 1}) = m[n] ||= fib(n-1)+fib(n-2)` 21:00
oh, does raku let you easily do stuff like defining methods dynamically? eg in ruby `define_method :name do |...| ... end` 21:01
(idk if you can tell but ruby's my language of choice lmao)
or, in ruby, `define_method(:get_http, &Net::HTPP.method(:get))` 21:03
guifa2 Yeah
m: class A { A.^add_method: 'foo', { 'hi' } }; say A.foo
evalable6 hi
guifa2 to be totally generic
$?CLASS.^add_method: … 
sampersand oh that's
s/s/s cool/ 21:04
guifa2 $?CLASS is replaced by the compiler by whatever the current class is
sub foo is really just shorthand for 'our &foo = { … }'
sampersand someone on the discord introduced me to `unit module Knoight::Null;`. nice
and `sub foo($x, $y)` is `-> $x, $y `, right?
guifa2 Functionally, yeah. Technically -> $x, $y { … } is a Block 21:05
but subs, blocks, etc, are all Callables and that's the important bit 21:06
sampersand oh speaking of callables, ive found i use the `$` sigil far more than i did in perl. is that normal for raku?
also, the heck is the `\` sigil? and whats `*` 21:07
guifa2 Eh, it depends on what you're coding. Theoretically, for the same thing, you should be using it less, since Raku uses @array[$item], whereas Perl would use $array[$item]
sampersand and is `*` used for anything like it is in Perl? *
guifa2 \ means "no sigil"
sampersand yeah, it's probably just becaue Knight doesn't use arrays a ton
guifa2 m: my \a = 5; say a
evalable6 5
sampersand why would you have a sigilless thing?
guifa2 everyone has different reasons ha 21:08
but they range from emphasizing immutability (you can't reassign into a sigil-less)
sampersand "I like javascript, so im going to remove my sigils from raku"
ah ok that makes sense
21:08 hvxgr joined
guifa2 to avoiding dealing with containers 21:09
for instance, if I expect someone to maybe pass me an array, maybe a scalar
if I use sub foo ($a), the array will be containerized
sampersand ah
guifa2 if I use sub foo(\a), things will be passed through as is 21:10
* is a Whatever. So … it's Whatever You Want™
see perl6advent.wordpress.com/2017/12/...of-perl-6/
* and : get lots more use in Raku than in many other languages hahah 21:11
sampersand yeah i know, i love the asterisk
but is there an equiv of perl's `*a = *b`?
s/\*b/b/
guifa2 ehe, closest you'd get is :: I think (if I remember my perl) 21:13
to access symbol tables
sampersand i never used it in perl lol, just curious
guifa2 m: my $a = 5; say ::.keys
evalable6 ($a $! !UNIT_MARKER $=pod EXPORT $_ $/ $¢ $?PACKAGE $=finish GLOBALish ::?PACKAGE)
guifa2 along with lots of ones like GLOBAL:: etc but you'd need to ask someone who's more tuned to that lower level perl stuff
sampersand do i do `unit role Value is export` or is the is export implied 21:14
guifa2 implied for unit declarations, IIRC 21:15
sampersand ok
guifa2 but try, and if it doesn't work, add in is export ;-)
sampersand this is cool: `unit class String does TypedValue[Str, * cmp *, * eq *];`
lol, im not a the point yet where i can try that xd i just wanted to kknow if i needed to add it to my 6+ files 21:16
guifa2 is afk&
sampersand okedoke
how can i predeclare a class within a unit role definition? 21:19
eg `unit role Value ; class Identifier { ... }` 21:20
im getting `Cannot declare our-scoped class inside of a role`
codesections maybe `my class Id {}`
sampersand nope 21:21
codesections hmm, not sure then, sorry
sampersand also im not a huge fan of how raku uses `...` to mean "prototype" lol, as it's always what I use when i just elide code normally xd
any workarounds? 21:22
my `Value::assign` needs `Identifier`, but `Identifier` needs a `Value`
OH OH OH also, do people generally have the comma in `sub foo(Int $x, --> Int)` , or is it usually `sub foo(Int $x --> Int)` ? and does that change if you have multiple parameters, eg `sub foo(Int $x, Int $y --> Int)` 21:23
codesections what are trying to do? I don't think of Classes as living in Roles...
sampersand here let me commit my code 21:24
So `Identifier` needs `Value` (github.com/sampersand/knight/blob/...kumod#L1), but `Value` needs `Identifier` (github.com/sampersand/knight/blob/...kumod#L18) 21:25
(well, the `NonIdempotent` requires `Value`) so im trying to resolve circular deps 21:26
codesections Without digging too much into the code, it looks like you could `use` Identifier rather than define it? 21:29
sampersand so `Identifier` requires `NonIdempotent`, and `NonIdempotent` requires `Value`
so wouldnt `use Identifier` then create a circular dep
codesections oh, I'm with you now 21:30
sampersand in kKight, `= a 3` assigns `3` to `a`, but `= (+ "a" 9) 4` assigns `4` to `a9`
assignment and equality are the only times when the type of a variable matters—every other time, values are coerced to the type that's needed. I did equality fairly eqasily with `multi` methods. but this is just a thorn 21:31
docs.raku.org/language/faq#index-e...cies_(FAQ) is not promising
codesections thinking out loud a bit: NonIdempotant feels like a behavior that (some) values have. Would it make sense for some Values to do NonIdempotant rather than the other way around? 21:33
sampersand well, so the idea is there's two categories of types: literals (Numbers, Strings, Booleans, and Null), which when evaluated just  return themselves 21:34
then there's functoins and identifiers, which, when evaluated, don't simply return themselves 21:35
codesections right
sampersand so i originally had `NonIdempotent` as a class, and had things inherit from it
i forget why, but some error forcedme to flip it around
also, pardon my atrocious typing lol, my fingers cant keep up with my head 21:36
codesections I guess what I was thinking is that it could be a roll that fns and idents `does` 21:37
would that not work?
sampersand yeah 21:38
i mean wait, dont they already do that
`unit class Identifier does NonIdempoten;`
codesections ok, so what I was saying is `class Identifier does Value does NonIdempotent` 21:39
then it's both, without either needing to inherit 21:40
sampersand oh
hm ok true
codesections composition over inheritance and all that :)
sampersand yeah 21:41
inheritance is bad ;p
codesections ok, I'm stepping out for a bit
21:41 rindolf left
sampersand aight 21:41
22:12 wamba joined, gnufr33dom joined
sampersand ok its so cool how raku has `say 1 ≠ 2'` 22:31
does anyone use the unicode characters in production or anything? or are they gimmicks
22:57 jmerelo left 22:59 aluaces_ left
sampersand beuler 23:05
23:15 Discipulus left 23:33 monkey__ joined
guifa2 sampersand: circular dependency requires all things to be in a single file, but you have the predeclaration correct 23:36
class A { … }; class B { has A $.a }; class A { has B $.b } 
if you *really really* want them in separate files, you can use indirect look ups 23:37
class A { has ::("B") };
class B { has ::("A") $.a }
that is resolved at run time, rather than compile time, and lets you get away with things you otherwise shouldn't be able to 23:38
but it's code smell IMO
sampersand woah lots of pings 23:41
hm
ok if tis a code smel, how can i fix it
guifa2 use the first example I gave you 23:42
Predeclaration (called generally forward declaration in the docs) in and of itself is fairly common: I use it a lot when I want to shift the order of classes in my file to start with the big stuff and then work my way down 23:44
sampersand > `class A { … }; class B { has A $.a }; class A { has B $.b } ` this?
guifa2 yes
sampersand oh shit sec, puppy is marking
ok yeah guifa2i was doing that before, but i wanted to split it out froma  single `.raku` file 23:48
guifa2 Which two things are you needing to split out from your code? There might be another way 23:50
sampersand hm well ok
`Value` is the parent class of everything 23:51
the idea is there's two types in knight: literals ( `Number` , `String` , `Boolean` , `Null` ) which, when evaluated, just return themselves
then there are `Identifier` and `Function` that, when evaluated, may return something different each time.  All of them, however, are `Value` s
guifa2 Yeah, if either Identifier or Function can return each other, you don't really have any way other than what I explained above. But the question would be how they're arriving at those values. If they're just passing stuff through, you can just type things as Value and not worry. I'd need to look at the code more in depth. About to make dinner tho 23:57