stevied | well, finally getting more comfortable with comma. feeling like I can do useful work with it, at least | 00:03 | |
01:16
sisar joined
|
|||
sisar | Hi! Is there a tutorial on how to organize my code into different files, and then using the subroutines, classes, grammars, etc. in other files? I tried reading docs.raku.org/language/module-packages but got quite confused. | 01:22 | |
stevied | are you writing a module? | 01:24 | |
or are you just creating a loose library of standalone scripts? | |||
sisar | ... and related, any recommended way to organize my files/directories? Like ".rakutest" files go in the "t/" directory, you main script goes in the projects "root" directory, where do my utils file go, etc. ? | ||
if you are asking if i'm writing a "module" for sharing on modules.raku.org/ , then no. (At least not yet.) | 01:26 | ||
i just want to break up my large file into various small files | |||
stevied | if you are writing a package, your main code goes into the a lib/ directory, typically | ||
sisar | I'm just so confused with the words "package" and "module". | 01:28 | |
I know Java. So are Raku packages same as Java packages? | |||
stevied | yeah, so sounds like if you create a ~/raku directory and just throw your raku scripts into there. any code that you want to reeuse can go into the ~/raku/lib directory | ||
Then, to use those packages just do `use My::Package` and `lib 'lib'` in your scripts in ~/raku | |||
basically interchangeable | 01:29 | ||
packages are usually distributed as a standalone group of files with tests and everything bundled together | 01:30 | ||
a module is typically one file of related functions | |||
oh, sorry, flip that around | 01:32 | ||
packages are usually just a file and modules are distirbuted | 01:33 | ||
it can be confusing because the terms are often used interchangeably | |||
sisar | before i do `use My::Package;` in my main script in the `~/raku/` directory, what do I need to declare at the top of all my files in the `~/raku/lib/` directory? | 01:34 | |
do i put a `unit package My::Package;` at the top of every file in `~/raku/lib`? | |||
stevied | `package My::Package` | 01:36 | |
sisar | ok, i'll try all of this now | 01:38 | |
thanks! | |||
stevied | ok, good luck. oh and it's `use lib 'lib'` by the way. | 01:41 | |
sisar | Comma says "Semicolon form of 'package' without 'unit' is illegal." | 01:44 | |
Looks I need to write `unit package My::Package;` instead of `package My::Package;` at the top of my files in `lib/` | |||
or i drop the semicolon ? | 01:45 | ||
stevied | ok, yeah. I"m still new at this, too | ||
you need the semi | |||
docs.raku.org/syntax/unit | 01:47 | ||
so I guess technically you could do: `unit package { code goes here }` | 01:49 | ||
nope, slight wrong. just `package { code goes here }` | 01:50 | ||
by throwing `unit` in front of it you need the semi colon | 01:51 | ||
I'm not sure what the difference is between `unit package` and `unit module` . I didn't even realize they were two different things. Will have to read up on it. | 01:55 | ||
looks like modules are a type of package. but i'm not sure when you'd use it instead of a package | 01:57 | ||
02:21
sisar left
|
|||
CIAvash | stevied: `package` is like keywords such as `class` where you need to give it a block, so `package P { ... }`. But using `unit package P;` makes the whole unit(file) a package, so you don't need to pass it a block. | 05:31 | |
"makes the rest of file a package" is correct | 05:35 | ||
modules, classes other things that create namespaces are a kind of package. packages are mostly only for creating namespaces, while you do other things with other kind of packages. One distinction the docs mention is that packages have to identity(`ver`, `auth`). So we can see packages are the simplest form of creating a namespace. | 05:46 | ||
08:48
dakkar joined
08:55
Manifest0 left
09:00
Manifest0 joined
10:28
TempIRCLogger left
10:29
TempIRCLogger joined
10:33
TempIRCLogger left,
TempIRCLogger joined
10:34
zacts joined
|
|||
stevied | is there a regex character for "all whitespace except newline?" | 10:42 | |
lizmat | <[\s]-[\n]> ? | 10:43 | |
stevied | weird. that looks like a range | 10:44 | |
lizmat | a character class consisting of whitespace minus a character class consisting of newline | 10:45 | |
stevied | wow, didn't know that was possible. thanks | 10:46 | |
lizmat | m: dd "4" ~~ / <[\d]-[5]> / | 10:47 | |
camelia | Match.new(:orig("4"), :from(0), :pos(1)) | ||
lizmat | m: say "4" ~~ / <[\d]-[5]> / | ||
camelia | 「4」 | ||
lizmat | m: say "4" ~~ / <[\d]-[4]> / | ||
camelia | Nil | ||
10:47
zacts left
|
|||
tbrowder | wouldn't <[\h> | 10:48 | |
sorry... <[\h]> work? | |||
lizmat | docs.raku.org/language/regexes#ind...and_ranges | ||
stevied | worked. awesome. wish I asked sooner. I've been going nut writing this grammar | ||
Nemokosch | so yeah, minus means exclusion (inside the pointy brackets I guess?) | 10:49 | |
lizmat | tbrowder: that could also work perhaps :-) | ||
stevied | not sure \h would work on \r\n thought, would it? | ||
lizmat | I was more triggered by the "all ... except ..." | ||
tbrowder | but yr meth is so instructive! learned something new again | 10:50 | |
Nemokosch | or are ranges with the dots only? | ||
tbrowder | stevied: good question. someone with steady hands could demo that | 10:51 | |
stevied | i'll have to toy with it later. I'm going to to to bed on a good note. | 10:53 | |
Finally got a basic understanding of at least simple grammars now | |||
ready to take on protos (I think) | |||
thinking about it more, \h would capture \r which is a newline character for macos. so that would probably be a bigger problem | 10:55 | ||
11:04
razetime joined
12:13
razetime left,
razetime joined
|
|||
tbrowder | m: my $line = "foo\r"; say $line ~~ /<[\h]>/ | 12:15 | |
camelia | Nil | ||
tbrowder | m: my $line = "foo\r"; say so $line ~~ /<[\h]>/ | 12:16 | |
camelia | False | ||
tbrowder | looks like \r is not captured by \h | 12:17 | |
lizmat | docs.raku.org/language/regexes#ind...h_and_%5cH | 12:19 | |
I don't think CR is considered horizontal whitespace | |||
m: say "\r" ~~ / \v / | |||
camelia | |||
lizmat | m: dd "\r" ~~ / \v / | 12:20 | |
camelia | Match.new(:orig("\r"), :from(0), :pos(1)) | ||
lizmat | yeah, \r is vertical whitespacve | ||
12:21
discord-raku-bot left,
discord-raku-bot joined
14:46
wingfold joined
|
|||
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/03/21/2022-...easomatic/ | 14:56 | |
16:26
colemanx joined
17:05
razetime left
|
|||
stevied | ah, interesting. so \h can safely be used instead of <[\s]-[\n]> | 17:31 | |
17:36
dakkar left
17:57
m_athias left
17:58
m_athias joined
18:04
wingfold left
18:05
camelia left,
m_athias left
18:06
m_athias joined
18:14
camelia joined
|
|||
ionsolo | how remove emojis from Str? | 18:15 | |
well I think the property of unicode could help but I don't known which one | 18:17 | ||
lizmat | m: say "foo😭bar".subst( / <:Emoji> /, :g) | 18:22 | |
camelia | foobar | ||
lizmat | ionsolo ^^ | 18:23 | |
Nemokosch | :DD | ||
stevied | questions, I am full of them: stackoverflow.com/questions/715630...-id-prefer | 19:23 | |
20:21
wingfold joined
20:53
Oshawott joined
21:34
wingfold left
21:57
destroycomputers left
|