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. |
|||
08:07
dakkar joined
10:14
habere-et-disper joined
10:16
frost joined
|
|||
habere-et-disper | How do you subset a Pair ? | 10:26 | |
I tried: | |||
m: subset File-Rank of Pair where (Str => Int); my File-Rank $foo = 'd' => 4; | |||
camelia | Type check failed in assignment to $foo; expected File-Rank but got Pair (:d(4)) in block <unit> at <tmp> line 1 |
||
Nemokosch | two things | 10:28 | |
to answer the question: you can probably write a check utilizing .key and .value | 10:29 | ||
where { .key ~~ Str && .value ~~ Int } | |||
second: keep in mind that a Pair is not meant to be used as a tuple. The two elements have a hierarchic relation, moreover the key cannot have a container while the value can | 10:30 | ||
the key is really meant to identify the value. Just to make sure you know what you are going for. | 10:31 | ||
10:32
frost left
|
|||
habere-et-disper | Thanks Nemokosch. I had wanted something more succinct like the documentation gives for other types, eg: `subset Foo of List where (Int,Str);` but I guess not. | 10:33 | |
Thank you for the tuple distinction. Awareness created. :D | 10:36 | ||
Nemokosch | The lack of proof is not the proof of lack so there could be something like that still 😛 | 10:39 | |
that's mostly a matter of smartmatching, though, so one would need to check Pair.ACCEPTS | 10:40 | ||
According to Rakudo sources, a $pair1 ~~ $pair2 if and only if $pair1.key ~~ $pair2.key && $pair1.value ~~ $pair2.value... which tells me that it could work | 10:45 | ||
oh, gotcha... | 10:47 | ||
dd Str => Int | |||
m: dd Str => Int | |||
Raku eval | :Str(Int) | ||
Nemokosch | this still doesn't give it away but hold on | ||
m: dd (Str => Int).key | 10:48 | ||
Raku eval | "Str" | ||
Nemokosch | there | ||
it is not the type but simply the string Str, that's why another string doesn't smartmatch to it | |||
lemme join quickly, the IRC bot is more up-to-date | 10:50 | ||
10:50
Nemokosch joined
|
|||
Nemokosch | m: subset File-Rank of Pair where ((Str) => Int); my File-Rank $foo = 'd' => 4; say $foo; | 10:51 | |
camelia | d => 4 | ||
Nemokosch | dang! | ||
m: subset File-Rank of Pair where ((Str) => Int); my File-Rank $foo = 21 => 4; say $foo; | |||
camelia | Type check failed in assignment to $foo; expected File-Rank but got Pair (21 => 4) in block <unit> at <tmp> line 1 |
||
Nemokosch | m: subset File-Rank of Pair where ((Str) => Int); my File-Rank $foo = 4 => 'd'; say $foo; | ||
camelia | Type check failed in assignment to $foo; expected File-Rank but got Pair (4 => "d") in block <unit> at <tmp> line 1 |
||
Nemokosch | habere-et-disper: TLDR, ((Str) => Int) works; the key needs to be disambiguated from unquoted strings | 10:52 | |
10:52
Nemokosch left
|
|||
lizmat | m: subset File-Rank of Pair where Pair.new(Str,Int); my File-Rank $foo = 4 => 'd'; say $foo; | 11:05 | |
camelia | Type check failed in assignment to $foo; expected File-Rank but got Pair (4 => "d") in block <unit> at <tmp> line 1 |
||
lizmat | m: subset File-Rank of Pair where (Pair.new(Str,Int)); my File-Rank $foo = 4 => 'd'; say $foo; | ||
camelia | Type check failed in assignment to $foo; expected File-Rank but got Pair (4 => "d") in block <unit> at <tmp> line 1 |
||
lizmat | weird | ||
habere-et-disper | LOL. Thanks for all this ! I see the chess board alternatives as : | 11:15 | |
`subset File-Rank of Pair where ( ('a'..'h') => 1..8 );` | |||
or better as a tuple and with far less parentheses: | |||
`subset File-Rank of List where 'a'..'h', 1..8;` | |||
13:04
habere-et-disper left
13:29
jgaz joined
|
|||
Anton Antonov | I have a variable that has a grammar name, say, $grName . I want make a new grammar that inherits from $grName and uses its TOP rule. How do I do that? | 13:40 | |
I tried grammar New is ::($grammarName) {...} but I am getting the message: "Cannot stringify object of type QAST::Var". | 13:41 | ||
lizmat | is $grammarName set at compile time? | 13:42 | |
Anton Antonov | Hm... yes. I have a statement like my $grName = "R322"; . Then I use EVALFILE($*CWD ~ "/resources/$grName.raku");. | 13:44 | |
Maybe I should use an actual grammar object in the inheritance specification? But, then again, how do I do that? Here is the grammar object: my $gr = EVAL $grCode. | 13:46 | ||
lizmat | how would you do it if they were ordinary classes ? | 13:47 | |
Anton Antonov | @lizmat It is a good question -- I do not know. | 13:52 | |
I can use another call to EVAL to construct the new class or grammar. (Simple.) | 13:59 | ||
moritz | isn't there like a add_parent_class meta method? | 14:00 | |
Anton Antonov | @moritz I looked into the meta programming documentation pages. Without finding something relevant, but I did not look that hard... | 14:01 | |
moritz | there's an `add_parent` method in src/Perl6/Metamodel/MultipleInheritance.nqp | 14:03 | |
the meta model is sadly very under-documented | |||
Anton Antonov | Cool! | 14:04 | |
14:11
tea3po left
14:12
tea3po joined,
tea3po left
14:13
ab5tract joined,
tea3po joined
|
|||
Nemokosch | On one hand it is sad, on the other hand, if it's not Raku and its stability is not guaranteed, maybe documenting too much of it would also be pointless | 14:16 | |
14:36
Heptite joined
14:52
deoac joined
|
|||
moritz | you can make it Raku by documenting it and writing tests for it | 15:08 | |
gfldex | moritz: it's a bit more involved, see: gfldex.wordpress.com/2023/02/15/yes-but-dont/ | 16:16 | |
Nemokosch | And the title is perfectly fitting | 16:34 | |
Yes, you can, and please don't. There is already more than enough Rakudo in Raku | 16:35 | ||
16:37
jgaz left
16:39
dakkar left
|
|||
moritz | gfldex: I don't see how the code from your post and documenting metamodel methods relate | 17:00 | |
ah, you actually meant the part where you you have to compose the class again | 17:01 | ||
17:13
ab5tract left
17:58
jgaz joined
18:15
jgaz left
18:30
deoac left
19:27
ab5tract joined
19:54
ab5tract left
21:20
orylesor joined
|
|||
orylesor | Hi. Call me Teresa. (she/her) | 21:29 | |
I'm an absolute beginner. Evaluated expressions in different programming languages, I understand basic programming concepts, I'm comfortable setting up programming languages and related tools, comfortable with the command line. | |||
I'd just like to finally learn programming "proper" just for fun. I always had false starts. I absolutely love x86-64 assembly, I spent a few weeks with it. I could definitely keep going with it, I'm just concerned that I wouldn't learn programming "proper", whatever that means, since it's not even a programming language. I'm also very tempted to | |||
get back to Raku (tried briefly before), I like the flexibility, I like "0.1 + 0.2 = 0.3", it's super cute. | |||
I just can't make up my mind on what to do: Analysis paralysis. Sorry if this is totally off-topic, and that it's admittedly irrational. I just thought if I said my thoughts out loud, I might get unstuck. | |||
Thanks. | |||
falsifian | Good luck finding your path, orylesor! | 21:31 | |
orylesor | Thanks. <3 | ||
22:38
orylesor left
|
|||
Anton Antonov | @orylessor Consideb trying out, “just using” Raku packages you like. Scan raku.land… | 23:40 | |
I.e. raku.land . |