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. |
|||
habere-et-disper | Thanks again! | 00:00 | |
Nemokosch | I'm not sure what to do about it but I can understand that the situation is far from optimal... | 00:01 | |
00:05
NemokoschKiwi joined,
NemokoschKiwi left
|
|||
github.com/Raku/doc/blob/master/wr...#preambles | 00:08 | ||
to be honest, I don't think that justifies the omission of parts that are required for the proclaimed output | 00:16 | ||
00:17
Kaiepi left
|
|||
FYI github.com/Raku/doc/issues/4138 | 00:37 | ||
00:43
habere-et-disper left
01:20
razetime joined
01:31
sgrs left
03:06
Kaiepi joined
03:43
MasterDuke left
05:03
Heptite left
07:52
razetime left
08:10
razetime joined
08:29
Kaiepi left
09:11
dakkar joined
09:21
razetime left
09:22
razetime joined
10:03
Kaiepi joined
10:34
equinox joined
10:41
mat40 joined
10:45
mat40 left
12:04
habere-et-disper joined
12:45
equinox left
|
|||
Hello, how can I figure out the exact number of significant bits of an Int? | 12:50 | ||
13:27
sgrs joined
13:55
equinox joined
14:05
habere-et-disper left
|
|||
yabobay | ```pl | 14:28 | |
my &some = sub { | |||
sub ($thing) { | |||
} | |||
}(); | |||
``` | |||
is there a more proper way to do closures? | |||
Nemokosch | Well, why did you wrap it into a function that you execute right away? What is the purpose? | 14:33 | |
yabobay | in my actual code i make some variables in that anonymous function | ||
that are used by the function inside it | |||
14:35
equinox left
|
|||
Nemokosch | you know... I'd be curious if a simple do block is sufficient | 14:38 | |
```perl | 14:39 | ||
my &some = do { | |||
# Last instruction | |||
sub ($thing) { | |||
} | |||
}; | |||
``` | |||
yabobay | isn't a do block the same thing as {}()? | 14:42 | |
Nemokosch | > do is equivalent, as in other cases, to surrounding a statement with a parenthesis. It can be used as an alternative with a (possibly more) straightforward syntax. | 14:44 | |
well, sounds like that | |||
but that does look better, no? xD | |||
yabobay | it does | 14:50 | |
i kinda phrased my question wrong | |||
i meant that it being the same thing is what i wanted | |||
Nemokosch | docs.raku.org/language/functions#i...y-closures | ||
> All code objects in Raku are closures, which means they can reference lexical variables from an outer scope. | |||
so I'd assume that you don't even need them to be subroutines, blocks will do | |||
Kaiepi | `do`'s like writing `-> { }()` | 14:59 | |
should be ok here | 15:00 | ||
if the block's error prone, maybe exposing a `sub named() { }` would be more appropriate | 15:04 | ||
then it could be tested | |||
yabobay | there's a Inline::Python module which can be used like this: | 15:25 | |
```pl | |||
use Inline::Python; | |||
15:25
Heptite joined
|
|||
my $py = Inline::Python.new(); | 15:25 | ||
$py.run('print("hello world")'); | |||
# Or | |||
say EVAL('1+3', :lang<Python>); | |||
use string:from<Python>; | |||
say string::capwords('foo bar'); # prints "Foo Bar" | |||
``` | |||
and i'm trying to use a constructor from a python class like this: | |||
```perl | |||
my $a = translate::Translator(:from_lang('zh'), :to_lang('en')); | |||
a::translate($text); | |||
``` | |||
which gives me this error: | |||
``` | |||
Could not find symbol '&Translator' in 'translate' | |||
in sub at weirdfortunecookie.raku line 6 | |||
in block <unit> at weirdfortunecookie.raku line 29 | |||
SystemError: frame does not exist | |||
``` | |||
i guess constructors aren't functions the same way they are in python? | |||
(that's *all* the available documentation about Inline::Python btw) | |||
Nemokosch | perhaps it would be better to pretend there is no Inline::Python module 😅 | 15:29 | |
yabobay | is there any better way to use python classes then? | ||
15:30
razetime left
|
|||
Nemokosch | maybe not | 15:32 | |
> my $a = translate::Translator(:from_lang('zh'), :to_lang('en')); | 15:33 | ||
this syntax leaves me clueless, though... | |||
yabobay | well, Translator() returns an object | 15:34 | |
Nemokosch | tbh if there was something I liked about Python is that they ditched this whole :: madness | 15:36 | |
yabobay | is this even a thing i could possibly do | 15:37 | |
Nemokosch | As a rule of thumb, I wouldn't put too much effort into it | 15:44 | |
yabobay | yeah i've just decided to do it the easier but less satisfying way | 15:46 | |
or i guess the not at all way: | 15:49 | ||
Inline::Python can't use pip modules i guess | 15:50 | ||
Nemokosch | for me, the module resolution part worked | 15:52 | |
yabobay | i've got kind of a weird setup with rootless linuxbrew and both the python and the raku are installed from it | 15:53 | |
so maybe that's why it's having problems doing that | 15:54 | ||
```pl | |||
$py.run('import random'); # works | |||
$py.run('import translate'); # doesn't work | |||
``` | |||
Nemokosch | no problem for me | 15:56 | |
you have installed the module from pip, haven't you | |||
yabobay | yea | ||
there's basically no good reason to not just use python for this thing i'm doing tbh. | 15:58 | ||
but yknow, optimizing for fun or whatever | |||
even if i did install it from pip, what does it matter? i thouhgt that Inline::Python just runs a python on your system | 15:59 | ||
Nemokosch | No clue how it works tbh, probably some bridging business | 16:01 | |
yabobay | disappointment hour | 16:04 | |
Nemokosch | Well, for disappointments: it's important to set reasonable expectations. I would have been positively surprised if running Python from within Raku turned out to be swift. Proper linking with C ABI's is respectable enough. | 16:06 | |
This might be the most relevant experiment regarding Inline::Python | 16:07 | ||
github.com/p6steve/raku-Dan-Pandas | |||
yabobay | what if i | 16:08 | |
called the python code from c | |||
and then called the c code from raku | |||
(that's a joke but also would it be a thing i could do) | |||
lizmat | to an extent, that's how Inline::Perl works, afaik | 16:09 | |
yabobay | does perl5 have a good inline python module? | 16:10 | |
lizmat | metacpan.org/pod/Inline::Python | 16:11 | |
by the same author as Inline::Perl5 :-) | 16:12 | ||
Nemokosch | and the same author as Inline::Python for Raku... | ||
it seems to me that nobody believed this importing from Python would actually work | 16:15 | ||
yabobay | ```pl | 16:21 | |
use Inline Python => <<'END_OF_PYTHON_CODE'; | |||
def test(): | |||
return "AAAA" | |||
END_OF_PYTHON_CODE | |||
print test() ~ "\n"; | |||
``` | |||
in perl 5, | |||
brings this error: | |||
``` | |||
Couldn't find an appropriate DIRECTORY for Inline to use. | |||
at translate.pl line 1. | |||
BEGIN failed--compilation aborted at translate.pl line 1. | |||
``` | |||
Nemokosch | come on, don't you dare to "upgrade" to Perl 5 from Raku... 😅 | 16:25 | |
yabobay | haha no | ||
i will use perl5's Inline::Python | |||
and then raku's Inline::Perl5 | |||
Nemokosch | xdddd | ||
yabobay | i guess i can't get perl5 help in here though :p | 16:26 | |
lizmat | It's been 10+ years for me since I did some serious Perl work | 16:27 | |
Anton Antonov | @lizmat What fraction in the last 10 years did you spent on Raku? What is the second most prominently attended language? 🙂 | 16:56 | |
lizmat | I'd say 95% Raku, 4.99% Javascript and 0.01% Perl | 17:07 | |
Anton Antonov | Good to know! (Not going to be used against you.) | 17:33 | |
Well, I would not... | |||
17:34
dakkar left
|
|||
lizmat | the JS work was mostly for the irclogs.raku.org website :-) | 18:48 | |
Anton Antonov | @lizmat I am considering translating Raku plots into JS plotting libraries. (In order to use certain notebook solutions.) | 18:52 | |
yabobay | what does :: mean anyway | 19:48 | |
20:14
habere-et-disper joined
|
|||
habere-et-disper | I think it has infinite precision, but you can drill down with a more specific type: | 20:17 | |
m: say Int.Range | |||
m: say uint32.Range | |||
camelia | -Inf^..^Inf | ||
0..4294967295 | |||
habere-et-disper | m: say uint64.Range | ||
camelia | 0..18446744073709551615 | ||
Nemokosch | symbol lookup or sth like that | 20:30 | |
habere-et-disper | Should Real have a Range? | 20:34 | |
m: say Real.Range | |||
camelia | No such method 'Range' for invocant of type 'Real'. Did you mean 'rand'? in block <unit> at <tmp> line 1 |
||
20:39
ToddAndMargo joined
20:51
Kaiepi left
21:02
Kaiepi joined
21:29
sgrs left
|
|||
Nemokosch | for addressing a subroutine, we have &subroutine-name. What do we have for addressing a method? is there nothing better than ^find_method? | 21:29 | |
Kaiepi | you could put it in `my`/`our` to make it addressable with `&` | 21:50 | |
the default scope is `has` | |||
Nemokosch | what kind of scope is that? | ||
Kaiepi | a weird one | ||
Nemokosch | that much I could figure 😄 | 21:52 | |
21:53
sgrs joined
23:11
Kaiepi left
|