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. |
|||
00:16
discord-raku-bot left
00:17
discord-raku-bot joined
01:16
discord-raku-bot left
01:17
discord-raku-bot joined
|
|||
jaguart | irclogs.raku.org/raku/2023-01-04.html#01:34 | 02:15 | |
At the moment I limit Github tests on Windows to 2022.07 and they work ok | 02:16 | ||
02:17
discord-raku-bot left,
discord-raku-bot joined
03:03
rf left
03:17
discord-raku-bot left,
discord-raku-bot joined
03:48
rf joined
03:55
rf left,
rf joined
03:59
rf left
|
|||
stevied | Ran into something I couldn’t figure out: how do you get a method in a child class to call the parent class method? Tried various things like Parent.blah but nothing worked. | 04:02 | |
Couldn’t find any documentation for this from within the child class. Only from outside it. | 04:03 | ||
jack9 | `self.Parent`? | 05:13 | |
jaguart | Docs - docs.raku.org/language/objects#Inheritance which you probably already found, but redispatch is covered by docs.raku.org/language/functions#sub_nextsame and friends - in other words, up-the-inheritance chain might not mean what you think, so you can `nextsame` or `nextwith` and trust Raku to find the next candidate | 05:26 | |
actually - start reading the block on redispatch here: docs.raku.org/language/functions#Re-dispatching | 05:28 | ||
jack9 | what is the equivalent of `if __name__ == '__main__'` in raku | 05:31 | |
like this?``` | 05:33 | ||
if ($*PROGRAM-NAME eq $?FILE) { | |||
main() | |||
} | |||
``` | |||
07:14
destroycomputers left
07:15
destroycomputers joined
07:17
elcaro joined
07:20
Heptite left
08:17
discord-raku-bot left,
discord-raku-bot joined
|
|||
gfldex | <@842225380051124254> see: docs.raku.org/routine/MAIN | 08:35 | |
jaguart | @jack9 - maybe you are looking for docs.raku.org/language/variables#&?ROUTINE e.g. | 09:32 | |
jaguart | m: say &?ROUTINE.name | ||
camelia | ===SORRY!=== Error while compiling <tmp> Undeclared name: ?ROUTINE used at line 1. Did you mean 'Routine'? |
||
jaguart | m: sub x { say &?ROUTINE.name }; x | 09:34 | |
camelia | x | ||
Nahita | when you `import` a .py file, \_\_name\_\_ is set to the name of the file. when you run a .py file, it is set to "\_\_main\_\_" which allows to distinguish between running directly or importing | 09:37 | |
in Raku there are .raku files and .rakumod files so no need for this distinction perhaps | 09:38 | ||
10:23
Heptite joined
|
|||
Nemokosch | I also couldn't figure that out | 10:41 | |
Lately I've seen a peculiar method call syntax that might help: self.ParentName::methodName(arguments) | 10:59 | ||
jaguart | isn't assuming an inheritance hierarchy kind of an anti-pattern? vs nextwith() using the .^mro? | 11:17 | |
Nemokosch | I don't know if it is but it's better than nothing and that's how you would do it in C++ as well | 11:18 | |
jaguart | but nextwith() isn't nothing? | 11:19 | |
Nemokosch | it's definitely a smaller anti-pattern than tight coupling of inheritance and multiple dispatch which have very different goals and manifestations | ||
it's not even guaranteed to do the right thing if you have multiple candidates | |||
or better said, it probably won't do the right thing | |||
jaguart | yeah - which is why composition and roles are probably a better pattern | 11:20 | |
multi doesn't always work as I expect it - still having to train my brain | |||
Nemokosch | I consider this another design fault that might be too costly to do anything about it at this point | ||
and it's not particularly well documented, the least to say | 11:21 | ||
jaguart | this -> being inheritance or composition? | ||
Nemokosch | the fact that method hierarchy has no proper mechanism for itself | ||
it's just hacked into multiple dispatch | |||
jaguart | on the multi - is there a syntax for several types? e.g. `multi sub ( (Str | RatSr) $x )` or do I have to use a `where {}` | 11:22 | |
Nemokosch | I wouldn't know for one. Leaning more towards "no". If there is anyone who has a good grasp of syntax at the moment it's probably lizmat, with all the RakuAST work she's been doing recently | 11:23 | |
jaguart | oh interesting - I assmued that multis just sorted from most-to-least specific at each point in the ^mro... | ||
I also assumed that the ^mro was going to be definable / changeable given it's current implementation | 11:24 | ||
I will have to read up on Signature matching again | 11:25 | ||
Nemokosch | welp... literally, does anyone actually know the multiple dispatch resolution order? | ||
jaguart | it shows up in my grok tool - I just assumed the ordering from the MOP was meaningful 🤷♂️ | 11:26 | |
Nemokosch | it probably does have a logic - but not a logic that would be properly written down anywhere, it seems | 11:27 | |
and since it needs to handle the self and the parameters, the question of specificity is quite severe | 11:28 | ||
by the way. Sorry for hijacking the topic but I'm trying to estimate who would be willing to participate if we were to set up a "squashathon" | |||
jaguart | I'd give it a go - maybe if you gave me an example to do a couple of weeks ahead | 11:29 | |
is it like a nerdy zoomfest? or more tinezone distributed? | 11:30 | ||
Nemokosch | github.com/Raku/ecosystem-unbitrot this was the original version and this is my vision github.com/2colours/Raku-ideas/blo...0reborn.md | ||
ideas are also welcome about the format | |||
I'd be happy if we could get something real-time but yes, there needs to be some consideration of those who cannot be accessible in the same timeframe | 11:31 | ||
I think it's more a prerequisite to even know if there are people willing to participate and under what terms | 11:32 | ||
jaguart | Yeah - I'd like to participate | ||
Nemokosch | a format idea I have is: let's collect modules with accessible authors that can "use some sprucing up", as the fez tool would say | 11:34 | |
then give it some time while people can choose and do some of the possible tasks | |||
and there could be a kind of meetup where we can share results and partially also look for more stuff that might have come up | 11:35 | ||
jaguart | you could see about starting a new channel and use that to invite / exhort the troops - longer term, a place for newbies to start with small contributions and then sustain a fix a week etc. would be cook | ||
if you have a feel for peeps level you could pumpmaster them towards ones that you think would suit them and that would be useful | 11:36 | ||
Nemokosch | yes, I think this is something that could even just go to a news feed, similarly to the Rakudo weeklies | ||
jaguart | I think you might be better with the social aspects of a channel | 11:37 | |
Nemokosch | at this stage, my primary concern is to even get enough interest, to gather and estimate those people who are potential participants | ||
jaguart | maybe start your channel and send out a few invites... discord or irc work for me | ||
Nemokosch | depends on what channel. Discord is handy but I think it faces some (partially legitimate) rejection from the broader community, and so far I have bad experience with IRC - people just don't keep up with the different channels | 11:38 | |
regarding Discord - it occured to me yesterday that now that we have 3-4 regular learners showing up, even some casual voice sessions with whoever wants to discuss something about Raku, could increase cohesion | 11:40 | ||
jaguart | My feeling though is that you need the social interactive if you want steam. newsfeeds are low on my attention list, likewise reddit etc. | 11:41 | |
You could always use #raku I guess but the noise might annoy stalwarts | 11:42 | ||
or spin something up on Matrix / FossToDon | |||
or even twitter groups - my thought is it needs to be social casual, a place where it's ok to look a bit stupid 😶 | 11:44 | ||
in any case - post what you think, I'll sign up | 11:45 | ||
Nemokosch | Thank you for widening the perspective | ||
Not gonna lie, I don't like Reddit, and especially Twitter and its "spin-off" Mastodon, and this does have political reasons. These seem to exist for a certain type of people that definitely isn't me. | 11:46 | ||
tbh not just "isn't me", more like, we seem to be mutually incompatible | 11:47 | ||
jaguart | how about Matrix then? | ||
you can host your own | |||
11:49
discord-raku-bot left,
discord-raku-bot joined
|
|||
jaguart | on branding - I like #raku-rejuve - kind of like a school for delinquent newbies, on the path to rakuzen. | 11:50 | |
unbitrot looks like something that relay's irc chat ;) | |||
Nemokosch | rakuzen haha 😄 | 11:51 | |
yeah well, unbitrot existed in some form, for a couple of months or a year? I think there's stuff that can be reused but my vision is probably somewhat different | |||
jaguart | the Raku branding is way cool :) I have a soon to be released dist called Kaolin - clay for Raku (reusable components). | ||
Nemokosch | and perhaps the target itself shifted in the meantime | 11:52 | |
jaguart | raku-juve - pronounced joo-vee - it's your penitence for asking too much in the beginner channel - before you attain your raku zen. | 11:53 | |
oh - no objection to unbitrot - pronounced oon-bye-trot? and it does have a lot of dust to tidy | 11:54 | ||
Nemokosch | un+bit+rot | 11:55 | |
jaguart off to bet at 11pm Melb | |||
let me know and I'll sign up | |||
Nemokosch | okay, nighties | ||
jaguart blushes and covers the cam... | |||
11:57
discord-raku-bot left
11:58
discord-raku-bot joined
|
|||
lizmat | there is no such syntax atm, afaik | 12:40 | |
14:17
discord-raku-bot left
14:18
discord-raku-bot joined
|
|||
jack9 | what are the difference between blocks and functions | 14:42 | |
besides that blocks can be used in control flow statements | |||
Nemokosch | there is no return in block, that's for sure | 14:58 | |
I'm not 100% sure but you might be unable to use blocks for recursion | |||
well, to be more accurate about "return" | 15:02 | ||
if you do "return" inside a block, obviously it won't only terminate the block but the enclosing routine itself | |||
15:06
discord-raku-bot left,
discord-raku-bot joined
15:16
NemokoschKiwi joined
15:44
guifa_ joined
15:46
guifa left
|
|||
jack9 | m: | 16:00 | |
$fact = -> $n { | |||
n == 0 ?? 1 !! $n * $fact($n - 1) | |||
}; | |||
say $fact(10); | |||
m: | |||
my $fact = -> $n { | |||
n == 0 ?? 1 !! $n * $fact($n - 1) | |||
}; | |||
say $fact(10); | |||
m: | |||
my &fact = -> $n { | |||
$n == 0 ?? 1 !! $n * fact($n - 1) | |||
}; | |||
say $fact(10); | |||
m: | 16:01 | ||
my &fact = -> $n { | |||
$n == 0 ?? 1 !! $n * fact($n - 1) | |||
}; | |||
say fact(10); | |||
you can do recursion in blocks smh | |||
blocks are functions that don't return | 16:03 | ||
like procs in ruby | |||
Nemokosch | that's a very interesting order of binding tbh | 16:04 | |
jack9 | can i monkey patch a class like this?``` | 16:11 | |
class Str { | |||
method charcount() { | |||
self.comb.Bag | |||
} | |||
} | |||
``` | |||
Nemokosch | you might need some monkey pragma and the augment keyword | 16:12 | |
github.com/2colours/Int-polydiv/bl...iv.rakumod this is a module I created | 16:16 | ||
not sure if it's best practice, perhaps not | |||
but it does work | |||
and is an example as such | |||
it brings a polydiv method to Int | |||
(a counterpart of polymod) | |||
jack9 | not even this?``` | 16:19 | |
method charcount(Str:D:) {} | |||
``` | |||
Nemokosch | well, do try it 😄 | 16:20 | |
this is something I did once out of curiosity and pretty much that was it | |||
jack9 | m: | 16:21 | |
method charcount(Str:D:) { | |||
self.comb.Bag | |||
} | |||
say 'aaabb'.charcount | |||
m: | |||
my method charcount(Str:D:) { | |||
self.comb.Bag | |||
} | |||
say 'aaabb'.charcount | |||
what | |||
Nemokosch | well yeah, why would a plain dumb 'aaabb' string know about your method 😅 | 16:22 | |
it needs to be attached some way, that much is for sure | |||
probably with the metamodel | |||
jack9 | because i defined a `charcount` method to its type | ||
Nemokosch | well, not to its type, it's not living in the Str class | 16:23 | |
you made a constraint for a method floating in the sky | |||
jack9 | anyways what does `:U` and `:D` stands for | 16:24 | |
up and down? | 16:26 | ||
Nemokosch | U is, hm unfortunate xd | 16:31 | |
"Undefined", except it's rather "indefinite" which is a distinct concept | |||
And then D would be "definite" | 16:32 | ||
D is, like, give me a valid instance of this type | |||
U is like, give me a "hollow" instance - a type object - of this type | 16:33 | ||
The default value is, unless specified, the type object | |||
m: my Int $foo; say $foo; | 16:34 | ||
This is the same thing that 5.WHAT would return, actually. A type object fits the type constraint | 16:35 | ||
But it's not Int:D | |||
And conversely, 5 is not an Int:U | 16:36 | ||
If you subtyped Int, the type object of your subtype could be an Int:U | |||
Does this make sense? | |||
jack9 | hmm | 16:38 | |
16:40
discord-raku-bot left,
discord-raku-bot joined
|
|||
Nemokosch | 🙊 | 16:42 | |
By the way, there can be times when we can discuss stuff like this in the voice chat, if you want. I think some things could be easier. | 16:43 | ||
17:17
discord-raku-bot left,
discord-raku-bot joined
|
|||
stevied | alright, my latest creation is relatively mature: github.com/sdondley/Directory | 17:19 | |
feedback welcome | |||
I may add an iterator to it at some point in the future. I really need practice with iterators. they still kind of confuse me with that lazy loading stuff | 17:20 | ||
p6steve | <@563790557831495691> ... I came very close to using your %?RESOURCES module earlier (and then gave up on stupid resources anyway) | 18:01 | |
stevied | which one was that, the one that lets you use a menu to navigate it? | 18:02 | |
18:02
raku-discord joined
|
|||
raku-discord | <4stevied> which one was that, the one that lets you use a menu to navigate it? | 18:02 | |
<4raku-bot> <raku-discord> <4stevied> which one was that, the one that lets you use a menu to navigate it? | |||
<4raku-bot> <raku-discord> <4raku-bot> <raku-discord> <4stevied> which one was that, the one that lets you use a menu to navigate it? | |||
<4raku-bot> <raku-discord> <4raku-bot> <raku-discord> <4raku-bot> <raku-discord> <4stevied> which one was that, the one that lets you use a menu to navigate it? | |||
18:02
raku-discord left
|
|||
stevied | bot looks recursive | 18:02 | |
p6steve | <@563790557831495691> ... out of curiousity, when would I reach for Directory (instead of plain dir | ||
)? | |||
yes that one | 18:03 | ||
Zephyr | apologies for that, it's been fixed | ||
a new bridge was being tested and both bridges collided | 18:04 | ||
stevied | I created Directory mostly because I wanted to create a class with a `has Directory` attribute | ||
and it would do some basic checking for me to make sure it wasn't already a file, etc. | |||
p6steve | oh - OK so it's for OO style stuff - cool! | ||
stevied | then I decided to throw in some extra goodies like tying it in to IO::Dir and File::Directory::Tree so it could do some useful stuff too out of the box. | 18:05 | |
so it's just a little more convenient that IO::Path, especially for newbs. | 18:06 | ||
so it's just a little more convenient than IO::Path, especially for newbs. | |||
p6steve | nice! | ||
stevied | hides a layer of abstraction from them | 18:08 | |
p6steve | I need a way to get a dir sample test_data files (csvs) in GH /bin/test_data through zef install and accessible as an abs or rel filepath string by both bundled scripts and newly written scripts after the install ... the docs on Module resources are less than awesome ... can you maybe point me to a minimal module that can do that? | 18:11 | |
right now I just do a git clone after the zef install and use the files from there | 18:12 | ||
stevied | I don't know about a module but I recently wrote a script that can be adapted to search all the tarballs in the entire REA repository | 18:13 | |
It just gets the listings inside the tarball but with some tweaks it can read the files, too | |||
p6steve | ok - my guess is that all I need is in Distribution::Resources::Menu so I will pick that apart next time | 18:14 | |
stevied | ok, I misread your question | ||
p6steve | well I don't need to do the menu picker step | 18:15 | |
stevied | if I understand you, what I would do is put that data in /resources directory. then install it over to the user's home directory | 18:16 | |
I don't think you need my module for that | |||
you just have to know the path to the data | 18:17 | ||
p6steve | yeah - that's what I would like to do ... but I tried every combination of the docs and came up short ... do you know of a working example I could look at? | 18:18 | |
stevied | you only need to copy to the home directory if you are modifying them | ||
well, resources works just like a hash: off the top of my head you do something like `%*RESOURCES<path/to/file>` | 18:19 | ||
my memory is a little fuzzy | |||
docs.raku.org/language/variables#%?RESOURCES | 18:20 | ||
have you seen that? | |||
p6steve | yes ... that's what I couldn't get to work for me ... but I see that Distribution::Resources::Menu has test resources and so I will be able to plunder that for a working example!! perfect... | 18:22 | |
stevied | ok, cool. yeah, as far as I recally, you just throw your files and direcgtories into the /resources directory in your module | 18:23 | |
18:33
NemokoschKiwi left
18:48
josh24 joined
18:51
josh24 left
19:47
discord-raku-bot left
19:53
raku-discord joined
|
|||
raku-discord | <4stevied> I've got use Drectory in my script. Is there a way to determine which version of Directory the script is using? | 19:57 | |
<2Nahita> Directory.^ver maybe? idk | 20:00 | ||
<4stevied> my script insists on using a stale version of the module. no idea where it's getting it from | 20:01 | ||
<4stevied> oh, nvm. i'm using a different raku version in this shell. ugh | 20:04 | ||
<4stevied> just lost about 2 friggin hours trying to figure out why tests were acting so weird. | 20:06 | ||
20:13
raku-discord left,
discord-raku-bot joined
|
|||
gfldex | This is a bridge test. | 20:14 | |
stevied | I want to create a signature for the following scenario: if new is passed (), default $dir to '.'. If new is passed 'some string, I want $dir to be 'some string'. And if new is passed dir => '/some/dir', I want $dir to be 'some/dir' | 21:00 | |
so far, I have this: multi submethod BUILD(Str :$dir? = '') | |||
I guess I just need multi submehotd BUILD(Str:D $dir) | 21:02 | ||
gfldex | @stevied Str:D(Numerical) is a better constraing in your case. | 21:06 | |
stevied | ok, so I have this now: submethod BUILD(Str $dir-arg?, Str :$dir? = '', *%_ ()) and my $obj = Directory.new($dir-arg || $dir); just feels real awkward | ||
hmm, what does that do? | 21:07 | ||
gfldex | It wont fail on literal numbers. | ||
gfldex | m: sub foo(Str:D $s) { dd $s }; foo(42); | 21:08 | |
camelia | Type check failed in binding to parameter '$s'; expected Str but got Int (42) in sub foo at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
Nemokosch | Str:D is a bit broken with coercions, for that matter | ||
gfldex | m: sub foo(Str:D(Numerical) $s) { dd $s }; foo(42); | ||
camelia | ===SORRY!=== Error while compiling <tmp> Coercer is too complex. Only type objects, with optional type smileys, or empty parentheses, implying 'Any', are supported. at <tmp>:1 ------> sub foo(Str:D(Numerical)⏏ $s) { dd $s }; foo(42… |
||
stevied | huh | ||
gfldex | m: sub foo(Str(Numerical) $s) { dd $s }; foo(42); | ||
camelia | ===SORRY!=== Error while compiling <tmp> Unable to parse expression in typename; couldn't find final ')' (corresponding starter was at line 1) at <tmp>:1 ------> sub foo(Str(⏏Numerical) $s) { dd $s }; foo(42); |
||
Nahita | Numerical doesn't exist though, does it | ||
gfldex | m: sub foo(Str:D(Numeric) $s) { dd $s }; foo(42); | 21:09 | |
camelia | "42" | ||
gfldex | Raku's type system is so advanced, it is really easy to get wrong. :-> | 21:10 | |
21:11
rf joined
|
|||
stevied | all of it is tricky. a lot to keep track of | 21:16 | |
rf | Anyone know how to tackle this, I reinstalled Linux yesterday and I'm seeing: Aborting due to fetch failure: Test::META:ver<0.0.19>:auth<zef:jonathanstowe>:api<1.0> when trying to install Test::META | 21:24 | |
lizmat | feels like a connection issue, not a Raku issue ? | ||
rf | It's possible, but my internet is fine (at the moment), maybe my DNS is broken or something | 21:25 | |
lizmat | can you install other modules ? | ||
rf | Yeah, I can pull everything but this one module | 21:26 | |
Hmm, it's failing on a different module now, maybe I am having internet problems. | 21:28 | ||
lizmat | afk& | 21:29 | |
rf | Looks like Starlink (my ISP), is having issues. Well Humming-Birds new HTTPServer is delayed until that's fixed :L | 21:36 |