klebs | it is also possible to just write rules and tokens in a set of roles and then just compose sets of roles with "does" | 00:03 | |
so, in other words, you can have a file in your repository that looks like this: ```raku | 00:07 | ||
our class Handler { | |||
has $.exception-declaration is required; | |||
has $.compound-statement is required; | |||
} | |||
00:07
discord-raku-bot left,
discord-raku-bot joined
|
|||
so that's basically a little piece of a fuller grammar | 00:07 | ||
all in one file | |||
then you can have a number of these files | 00:08 | ||
maybe this one is called, for example gcpp-try.rakumod | |||
maybe this one is called, for example `gcpp-try.rakumod` | 00:09 | ||
so then you can have another file `gcpp-actions.rakumod` which has `Cpp::Actions` | |||
and `Cpp::Actions does Try::Actions does If::Actions does StringLiteral::Actions does etc etc etc {}` | |||
same thing with `Cpp::Rules does Try::Rules does If::Rules does StringLiteral::Rules does etc etc etc {}` | 00:11 | ||
but Cpp::Actions and Cpp::Rules are both roles... well at least Cpp::Rules is. Cpp::Actions can be a class if you dont want any further customization | |||
then, at the top, you can have a `grammar Cpp::Grammar does Cpp::Rules { rule TOP { ... } }` as well as a `class Cpp::Grammar::Actions does Cpp::Actions {} ` | 00:13 | ||
that's the strategy i use when the grammars are complex | |||
00:14
elcaro_ is now known as elcaro
|
|||
it might get a bit more complicated if you wanted to fit two grammars into one -- then you could follow that article | 00:15 | ||
you could, also imo gate access to a grammar subtree with a dynamic variable | 00:16 | ||
so in other words, when you detect that you are at a certain place in the tree, you can set a dynamic variable before accessing a toplevel rule for that subtree, which is gated by that dynamic variable | 00:17 | ||
ie, with <?{$*MY-GATE}> | 00:21 | ||
00:26
discord-raku-bot left,
discord-raku-bot joined
00:30
discord-raku-bot left,
discord-raku-bot joined
|
|||
stevied | yeah, i'm going to need a firmer conceptual map of how raku works before I can piece all that together. | 03:05 | |
by the time I'm done parsing out some of the syntax and looking at it, I lost sight of what I'm trying to figure out in the first place | 03:07 | ||
by the time I'm done parsing out some of the syntax and looking at it, I lose sight of what I'm trying to figure out in the first place | |||
klebs | i made this scrape -- hope it helps! | 06:09 | |
i read it all over a week or two before starting to write any raku and it helped immensely! | 06:11 | ||
couldnt remember everything right away of course, but it was great to get a sense of what the language could actually do | |||
highly recommend! | |||
(excuse the first page, which isnt useful) | 06:13 | ||
looking back at it, my explanation is a bit verbose -- basically, i am describing a way of breaking down a large grammar into many smaller roles which can be composed together, mixed and matched, etc. it makes it possible to model full languages, etc. useful for really anything you might encounter | 06:15 | ||
stevied | nice, i'll def check it out | 06:17 | |
klebs | np! enjoy! | ||
stevied | looks like it's in html format, is there a link? | 06:18 | |
klebs | oh, yea that's just the first page | ||
it is literally just a formatted scrape of all the pod files in the raku-doc repository | 06:19 | ||
so that it can be printed | |||
stevied | rest is pod | ||
klebs | for me, it made it easier to understand as a unit | ||
yeah pretty much | |||
there might be some odd formatting blips like that, but the information is more or less all there | |||
stevied | can you post a text doc that I can covert? | ||
klebs | github.com/Raku/doc/tree/master/doc | 06:21 | |
stevied | so is that the same documentation on the website? | ||
klebs | i think so yes | ||
i think it is the source for the website | |||
not totally sure how/when it is managed/synced | 06:22 | ||
so that pdf is basically a giant scrape of the website content as pod | 06:23 | ||
stevied | oh, i missed the part where you said you "made this scrape" | ||
klebs | it was done by just catting together all the pod files in that directory, running it through vim for the syntax highlighting, printing to xhtml and converting to pdf | ||
stevied | yeah, i've been going over the online documentation quite a bit | ||
klebs | i thought it was nice to be able to print it, go offline, carry it around, mark it up, etc while i initially learned | ||
that way i wouldnt consume it piece by piece online | |||
but could actually get it in one shot | 06:24 | ||
stevied | what explanation were you referring to, then? | ||
klebs | what do you mean? | ||
stevied | you said looking back you think your explanation was too long | 06:25 | |
klebs | oh, i meant what i was describing about the grammars/roles etc above | ||
the explanation before i sent the pdf link | |||
i was describing how to decompose a large grammar into a set of roles | |||
stevied | ok, gotcha. i thought you were sending me a basic overview of how raku works | ||
klebs | yea, that is the pdf! | 06:26 | |
that will describe pretty much everything | |||
stevied | heh, well, I wouldn't call that basic | ||
klebs | like learning to swim by jumping in the deep end! | 06:27 | |
it was actually pretty helpful to just hit the docs all in one shot right at the beginning | |||
i dont remember everything from them | |||
but i have this feeling in my mind when something should be possible | |||
stevied | that works for some who operate in a different symbolic plane than most mortals | ||
klebs | now i just started thinking in unicode | ||
"different symbolic plane" 🤣 | |||
stevied | but yeah, it's good to at least know what's out there even if you don't understand it right away | ||
a "known unknown" | 06:28 | ||
klebs | exactly | ||
stevied | my method is a little different | ||
i start at the shallow end | |||
then I get scared and wander back to the ankle deep water | 06:29 | ||
then I get brave and wade out a few more feet, get scared, then come back. repeat forever. | |||
klebs | it is a good way haha | 06:30 | |
need one of those floating foam things | |||
stevied | eventually, I'm swimming, but usually just because I'm flailing my arms around like a nut | ||
klebs | with raku, there are so many pieces which can make your life much easier a bit farther out | 06:32 | |
stevied | yeah, I definitely get that sense. | ||
then I come back and use perl and php and I'm like, this is so damn easy. | 06:33 | ||
but tedios | |||
but tedious | |||
klebs | raku is like a meta language in some respects | ||
im at the point where i wouldnt even attempt a thing in another language because i have raku | |||
when i say meta langauge im referring to how grammars, rules, regexes are so well thought out and integrated into the core | 06:34 | ||
stevied | yeah, I get that. but I gotta use it a lot and basically rewire my brain to think like that | ||
klebs | one great way is to translate something from one language into another with raku | ||
and then never repeat steps, so write raku functions for everything you find yourself repeating | 06:35 | ||
eventually u just get so fast doing taht | |||
stevied | i've been writing my new scripts in raku (but not bash scripts, too slow) | ||
klebs | me too | ||
i have basically completely dropped bash, python, awk, perl, etc etc for raku | 06:36 | ||
stevied | i wrote a couple of raku modules in my first week or two. Nothing fancy. but I impressed myself | ||
you write bash scripts with raku? | |||
klebs | yep, everything in the shell | ||
i have consolidated everything to raku and rust | |||
stevied | the start up time is too slow for me with raku. | 06:37 | |
klebs | those two languages are like a perfect pair in some ways | ||
stevied | probably a way around it but I don't know it | ||
klebs | yeah, i feel that too | ||
it would be nice if it was blazing fast | |||
right now it is like a super utility to me | |||
stevied | i'm sure it'll get there eventually | 06:38 | |
klebs | if i need to deploy something or want it fast/safe i just use rust | ||
but raku for everything else | |||
raku is the glue | |||
stevied | yeah, rust is getting into linux core now | ||
like a replacement for c I guess, in some cases | |||
klebs | i think it does that job well | ||
replacing c/c++ | |||
stevied | when I become a real programmer I'll check it out | 06:40 | |
klebs | when is that? 😁 | ||
stevied | i just don't have any real need to do any low level stuff | ||
hopefully within a couple more years. I decided to get serious about it a few years ago | |||
always just been a dabbler for the most part | |||
klebs | what do you like to use it for? | 06:42 | |
programs, that is | |||
programs (and programming languages), that is | |||
stevied | knew enough to hack someone else's php code or javascript or write bad spaghetti code in perl, but that was about it | ||
what do I use raku for? major think I'm working on right now is processing my markdown files that I publish | |||
building a hyper efficient system for writing and shareing notes in a wiki: climatechangechat.com | 06:44 | ||
raku will be my glue language for this project | |||
klebs | sounds like a good use case for raku! it is the best for anything with text! | ||
stevied | climatechangechat.com/raku-program...guage.html | ||
yeah, so far I'm liking it. just a lot of work to get proficient with it. | |||
klebs | nice! i subscribed to your youtube | ||
stevied | just started using Comma IDE which I determine is a must have. | 06:45 | |
thanks! yeah, I had to stop doing those for a bit. too much stuff going on but I plan to start it up again. on hiatus for at least a couple more months | 06:46 | ||
what kind of stuff do you write? | 06:47 | ||
klebs | writing some compilers/transpilers | 06:49 | |
so i do the parsing layers in raku | |||
stevied | yeah, you're hard core | 06:50 | |
klebs | i just love it haha | ||
stevied | grammars were totally foreign to me because I never had to write anything like a parser before | ||
klebs | i used raku to translate a synthesizer from c++ to rust | ||
stevied | but I do enjoy processing text for whatever reason | ||
klebs | then i started using raku to read back the rust program | ||
so i started to feel like raku could be used to read programs | |||
stevied | yeah, that kind of stuff is nuts | ||
klebs | break them down into their constituent parts, to fully understand the components | 06:51 | |
and then rearrange them to suit new tasks | |||
so that started to turn into a compiler system | |||
grammars were totally foreign to me when i first saw them too | 06:52 | ||
and then i realized they solve this problem i had all the time anyway | |||
in some way everything is parsing | |||
stevied | I've read enough about compiling to know it's ridiculously complicated | ||
squeezing out efficiences and that kind of thing | |||
klebs | it can teach so much about how to write better programs and do more with the machine | ||
stevied | yeah, I can imagine | 06:53 | |
klebs | first it has to understand the structure of the programs it encounters | ||
stevied | I get the big picture, but almost no details | ||
klebs | but then, all of this information gets built in which reflects more specific knowledge about how each architecture/target works | 06:54 | |
stevied | i can imagine once you learn that, everything else is just child's play | ||
my kid just started freshman year in college. I'm jealous | |||
computer science | |||
klebs | haha wow freshman year of college -- i'd run it back 🙂 | 06:55 | |
congrats | |||
stevied | yeah, he seems to enjoy it, but not the calculus courses. | 06:56 | |
alright, 3am here. gotta head off to bed. thanks for the chat. catch you later | 06:58 | ||
klebs | night! | ||
08:07
dakkar joined
09:01
MasterDuke left
09:11
MasterDuke joined
12:11
razetime joined
12:22
discord-raku-bot left
12:23
discord-raku-bot joined
14:17
zacts joined
|
|||
zacts | what's a good text or resource to learn how to program raku for a complete beginner thru advanced? | 14:19 | |
lizmat | www.reddit.com/r/rakulang/comments...ning_raku/ lists a few | 14:28 | |
zacts | thanks | 14:30 | |
16:23
discord-raku-bot left,
discord-raku-bot joined
16:47
dakkar left
|
|||
stevied | Is the Perl6 book still worth a look or is it too old? I’m thinking it’s probably the highest quality book but may be too far out of date. | 17:00 | |
17:03
razetime left
17:09
zacts left
17:47
zacts joined
18:01
zacts left
|
|||
lizmat | stevied if you mean Think Perl 6 (aka Think Raku), that *is* pretty much up-to-date | 18:04 | |
also Learning Perl6 is also pretty much up-to-date | 18:05 |