🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 6 September 2022. |
|||
01:22
SrainUser joined
|
|||
SrainUser | How do I import a function from a local raku file? | 01:23 | |
I typed "unit module foo" and "is export" for the file to export the function. I typed "use foo" as an import statement for the other file. I get an error saying it could not find foo. | 01:28 | ||
timo | if it's a local file, you'll need to tell rakudo to look locally, usually by supplying `-I folder` (which shouldn't be a huge folder, like your entire home directory, because it will be scanned) | 01:37 | |
if you're in a module, meaning you have a META6.json, that's where you'd have to have an entry for your module foo in the "provides" section | 01:38 | ||
01:44
guifa joined
|
|||
SrainUser | So a module in a file requires a META6.json file to tell raku to import from the current working directory? | 01:44 | |
timo | no, there's a third way which is `use lib ".";` or `use lib "thefolder";` in the raku script | 01:46 | |
it will look for files named with .rakumod extension by default | 01:49 | ||
gnite! | 01:52 | ||
SrainUser | It still does not find any module inside the ".rakumod" file. All I typed was "use lib ".";" and "use foo;" | 01:57 | |
timo | mkdir /tmp/srainmodule; cd /tmp/srainmodule; echo "unit module foo; sub footest() is export { say 'success'; }" > foo.rakumod; echo "use lib '.'; use foo; footest()" > main.raku; rakudo main.raku | 02:00 | |
this one-liner works on my end | |||
i've got to go sleep now, maybe this helps | |||
if you set RAKUDO_MODULE_DEBUG=1 in the environment, rakudo will output debug lines related to module loading, it should have lines in it like "Successfully handled 'lib' as a pragma", "try-load source at ./foo.rakumod", and near the end "Performing imports for 'foo'" and "Imports for 'foo' done" | 02:02 | ||
if it doesn't, maybe seeing where the success runs out helps figure out what's wrong | |||
SrainUser | Okay, Goodnight | 02:03 | |
timo | o/ | ||
SrainUser | I figured it out. The filename of the ".rakumod" file must be the name of the module it contains. | 02:22 | |
guifa | xinming: I should make a module Token::IP-String | 02:44 | |
Would go nicely with a project I'm workin gon anyways | |||
02:55
kylese left
02:56
kylese joined
03:15
kylese left,
kylese joined
04:44
Aedil joined
|
|||
Xliff | Anybody out there? .... out there....... out there ....... out there | 05:24 | |
How can I turn the integer 123456789012345 into its representative bytes? | 05:25 | ||
m: Bub.allocate(10).write-uint64(123456789012345).gist.say' | 05:26 | ||
m: Bub.allocate(10).write-uint64(123456789012345).gist.say | |||
camelia | ===SORRY!=== Error while compiling <tmp> Two terms in a row at <tmp>:1 ------> ).write-uint64(123456789012345).gist.say<HERE>' expecting any of: infix infix stopper statement end statement modifier… |
||
===SORRY!=== Error while compiling <tmp> Undeclared name: Bub used at line 1. Did you mean 'Sub', 'Buf'? |
|||
Xliff | m: Buf.allocate(10).write-uint64(123456789012345).gist.say | ||
camelia | Too few positionals passed; expected 3 or 4 arguments but got 2 in block <unit> at <tmp> line 1 |
||
Xliff | m: Buf.allocate(10).write-uint64(123456789012345, 0).gist.say | ||
camelia | MoarVM panic: Memory allocation failed; could not allocate 123456789012353 bytes | ||
Xliff | m: Buf.allocate(10).write-uint64(0, 123456789012345).gist.say | ||
camelia | Buf:0x<79 DF 0D 86 48 70 00 00 00 00> | ||
Xliff | Oh, nevermind. | ||
m: Buf.allocate(10).write-uint64(0, 123456789012345, BigEndian).gist.say # since intel is insane | 05:28 | ||
camelia | Buf:0x<00 00 70 48 86 0D DF 79 00 00> | ||
06:05
guifa left
06:42
samebchase joined
06:46
Sgeo left
|
|||
xinming | m: my $s = "hello"; (S/hel/aaa/ with $s).say; (S/hel/bbb/ given $s).say; | 08:38 | |
camelia | aaalo bbblo |
||
xinming | In this example, they both work, So the only diff between 'with' and 'given' are, 'with' will try to test the definied'ness of the $s, 'given' will always do the S/// Is my understanding right? | 08:39 | |
08:52
sena_kun joined
|
|||
Xliff | Yep. | 08:57 | |
my $a; (S/Aaa/bbb/ given $a).say | |||
m: my $a; (S/Aaa/bbb/ given $a).say | |||
camelia | Use of uninitialized value of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. (Any) in block at <tmp> line 1 |
||
09:05
Xliff left
|
|||
xinming | got it, thanks. | 09:21 | |
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/12/30/2024-...ate-rings/ | 12:38 | |
15:57
MoC joined
|
|||
antononcube | Is there any Raku module that tells (computes or retrieves) what are sunrise and sunset times of certain city or time zone? | 16:18 | |
tbrowder | antononcube: see Astro::Sunrise | 17:54 | |
lucs | Module loading question: gist.github.com/lucs/911dec0edc4df...00dd365ef1 | 18:01 | |
ugexe | probably because you are running code that prints in the mainline of a module | 18:05 | |
which would get run during precompilation | |||
lucs | Hmm... | ||
Ah. | 18:06 | ||
I can avoid doing that doctor. | 18:07 | ||
Shouldn't hurt anymore :) | |||
18:09
Altai-man joined
18:11
bartolin left
18:12
bartolin joined
|
|||
lucs | Heh. When I first noticed it was doing that, I kept trying to modify the code to see what was going on, resulting in a new precomp each time, and the same result. | 18:12 | |
Running it as is, no duplication. | |||
18:12
sena_kun left,
rypervenche left
18:13
rypervenche joined
|
|||
antononcube | @tbrowder Thank you! | 18:23 | |
18:45
MoC left
19:23
Aedil left
|
|||
xinming | Is it possible to die when var ia uniniailized? | 19:38 | |
timo | depending on where in your code it is you have multiple ways to do it | 19:39 | |
you can have a :D type smiley on the type of the variable, then an assignment with an undefined value will throw an exception | |||
xinming | It's not assignment, It's just when I try to print a string, the string has many vars, So it reports one of them uninitialized. I want the script to die with use of that var when print | 19:42 | |
timo | ah, your print is a long command with a bunch of variables in it, and any one of them might be undefined? | 19:44 | |
you are currently getting an "use of uninitialized value in string context" error? | |||
xinming | Yea | 19:45 | |
Use of uninitialized value element of type Any in string context | |||
I want to die with the variable name, So I can dump context to see what happened | 19:46 | ||
timo | ok not sure how exactly to get the variable name, but you can put `CONTROL { die "dieing because of this warning: $_" };` in front | 19:47 | |
ugexe | doesn't have to be in front | 19:48 | |
xinming | Thanks for the CONTROL phaser | 19:49 | |
Will try | |||
timo | CONTROL runs when any warning is emitted in the dynamic context of your function, which may be more than you want | 19:51 | |
also not just warnings are control exceptions | |||
you may want to match on the type in $_ being CX::Warn | |||
20:00
Altai-man left
20:03
sena_kun joined
20:31
Sgeo joined
20:36
xinming left
20:38
xinming joined
20:45
xinming left
21:20
guifa joined
|
|||
tbrowder | yw | 22:30 | |
hope it works for your needs | |||
antononcube | I am making a Doomsday Clock, in Raku. | 22:39 | |
But, the clock gauges can be utilized for showing, say, the times at different capitals. I want to also indicate with the color of the clock-faces is it night or day. | 22:41 | ||
22:53
sena_kun left
22:56
yewscion joined
23:03
yewscion_ joined,
yewscion left
|
|||
coleman | The only winning move is not to play | 23:39 |