This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
librasteve deoac: good question ... and snonux is right ... here's how I would describe it... 10:45
(i) the 'token' declaration is (like 'regex', 'rule' and so on) just a special kind of 'class' declaration since raku tries to build on the same lego bricks 10:46
(ii) all declarations ('class', 'constant', 'sub', 'method' and so on) have a default scope -- specifically 'class' (and thus 'token') take package scope 10:51
(iii) as you know there are two kinds of scope that can be used by declarations: 'my' is lexical scope, 'our' is package scope 10:52
(iv) by making class default to our scope, raku can make it much neater to write modules as OO classes 10:53
instead of package P { class A is export { has $.a = 42 } }
you can just write 10:54
class A { has $.x = 42 }
I have put this in a gist so that you can get a better feel for it gist.github.com/librasteve/4229147...58cfc60973
(v) but ... especially in larger programs there is a need for both public classes (the API) and private classes to coexist (the hidden implementation details) ... so raku lets you compound 'my' and 'class' to override the default scoping behaviour with eg. my token { ... } 10:57