|
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. |
|||
|
01:01
teatime joined
03:12
Sussysham joined
|
|||
| el gatito (** advocate) | cdn.discordapp.com/attachments/768.../image.png | 03:24 | |
| 😭 | |||
|
03:25
Sussysham left
03:40
rf left
05:28
Heptite left
06:46
teatwo joined
06:50
teatime left
08:58
frost joined
09:03
frost left
|
|||
| Nemokosch | What is this? | 09:16 | |
| el gatito (** advocate) | btw is a[1, 2, 3] interpreted as a.AT-POS((1, 2, 3)) or a.AT-POS(1, 2, 3) | ||
| Nahita | neither, i think | 09:46 | |
| that's 3 calls to AT-POS | |||
| Nemokosch | really, what does it actually do | 09:57 | |
| &postcircumfix:<[ ]>.sourcery(1,2,3) gives me github.com/rakudo/rakudo/blob/704a...ce.pm6#L16 | |||
| doesn't help | |||
| it's not the right candidate | |||
| oh I'm stoopid | 10:00 | ||
| &postcircumfix:<[ ]>.sourcery(@a, (1, 2, 3)) gives github.com/rakudo/rakudo/blob/704a...e.pm6#L119 | 10:01 | ||
| after a little chasing, it turns out that Nahita was right github.com/rakudo/rakudo/blob/d769...ce.pm6#L12 is called for all positions | 10:06 | ||
| el gatito (** advocate) | so its (a.AT-POS(1), a.AT-POS(2), a.AT-POS(3))? | 10:08 | |
| Nemokosch | yep | 10:09 | |
| el gatito (** advocate) | m:perl class A { method AT-POS($i) { say $i; $i; } } A[1, 2, 3] | 10:10 | |
| Raku eval | Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku A cannot be parameterized at /home/glot/main.raku:8 ------> A[1, 2, 3]⏏<EOL> | ||
| el gatito (** advocate) | m:perl class A { method AT-POS($i) { say $i; $i; } } say A.new()[1, 2, 3]; | ||
| Raku eval | 1 2 3 (1 2 3) | ||
| el gatito (** advocate) | this behavior feels inflexible | 10:11 | |
| Nemokosch | it makes sense though | 10:12 | |
| this operator is not something you should overload | |||
| however, you can overload AT-POS and get all the indexing possibilities | 10:13 | ||
| el gatito (** advocate) | it makes just as much sense if a[1, 2, 3] means a[1][2][3] as this | 10:19 | |
| raku doesn't allow you to have that option via AT-POS | |||
| Nemokosch | that's a[1; 2; 3] | ||
| check mate | |||
| el gatito (** advocate) | 😑 | 10:24 | |
| Nemokosch | and yes inb4 6.e will be shipping with || that flattens into semicolon list for indexing | ||
| el gatito (** advocate) | tried to install wsl via standalone appx package | 11:49 | |
| mb i have to upgrade even further 😓 | 11:51 | ||
|
12:51
QhpAptyj9hj0RQwM joined
|
|||
| so if i want (a[1; 2], a[3; 4]) i can a[(1; 2), (3; 4)]? | 12:52 | ||
| Nemokosch | wouldn't know without trying | 12:53 | |
| I would be more confident about the other way around | 12:54 | ||
|
12:56
QhpAptyj9hj0RQwM left
|
|||
| el gatito (** advocate) | m:perl say $_[(1; 2), (3; 4)] given ( (1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), ); | 13:01 | |
| Raku eval | (((5 6 7 8) (9 10 11 12)) (Nil Nil)) | ||
| el gatito (** advocate) | m:perl say $_[(0; 1), (2; 3)] given ( (1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), ); | ||
| Raku eval | (((1 2 3 4) (5 6 7 8)) ((9 10 11 12) Nil)) | ||
| el gatito (** advocate) | it gave some strange output lol | 13:02 | |
| ok what its actually doing is turning into a[0, 1, 2, 3] | 13:03 | ||
| funny behavior as always | 13:04 | ||
| m:perl say $_[(0; 1), 2] given ( (1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), ); | |||
| Raku eval | (((1 2 3 4) (5 6 7 8)) (9 10 11 12)) | ||
| el gatito (** advocate) | actually its even weirder | 13:05 | |
| Nemokosch | this ; thing is an operator, that's why I was fairly suspicious | ||
| lizmat | ; is an operator ? | ||
| Nemokosch | like, what even is (0 ; 1), a two-dimensional list? | ||
| el gatito (** advocate) | m:perl say $_[(0, 1), 2] given ( (1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), ); | ||
| lizmat | m: dd (0;1) | ||
| camelia | (0, 1) | ||
| Raku eval | (((1 2 3 4) (5 6 7 8)) (9 10 11 12)) | ||
| lizmat | m: dd (0,;1,) | ||
| camelia | ((0,), (1,)) | ||
| Nemokosch | m: dd (0 ; 1) | ||
| Raku eval | (0, 1) | ||
| Nemokosch | mmm | 13:06 | |
| el gatito (** advocate) | yeah same output | ||
| lizmat | a single value is not a list, it needs a comma | ||
| m: dd (0,;1,) | |||
| camelia | ((0,), (1,)) | ||
| lizmat | m: dd (0,1;1,2) | ||
| camelia | ((0, 1), (1, 2)) | ||
| lizmat | m: dd (0,1;1,2)[1;1] | 13:07 | |
| camelia | 2 | ||
| Nemokosch | 🤫 | ||
| el gatito (** advocate) | ok that makes a[0, 1, 2] and a[0; 1; 2] even weirder inconsistency | 13:08 | |
| lizmat | its not when you consider that (0) is **NOT** a list | ||
| (0,) *is* | |||
| Nemokosch | [; ] is a separate operator | 13:09 | |
| lizmat | suppose you want to initialize an array with some elements being lists and others not | ||
| how would you do that? | |||
| el gatito (** advocate) | [0, (1, 2), 3] | 13:10 | |
| lizmat | m: dd [0, (1, 2), 3] | ||
| camelia | [0, (1, 2), 3] | ||
| lizmat | hmmm | 13:11 | |
| Nemokosch | so iirc in a[0, 1, 2], 0, 1, 2 is data | ||
| however, in a[0; 1; 2], 0; 1; 2 is syntax | |||
| lizmat | ok, I guess there is something to be said to have ; inside circumfixes have their value to always be interpreted as lists | 13:13 | |
|
14:49
rf joined
15:37
Heptite joined
17:23
teatwo left
17:25
teatime joined
18:12
QhpAptyj9hj0RQwM joined
18:30
QhpAptyj9hj0RQwM left
18:46
teatwo joined
18:48
tea3po joined
18:49
teatime left
18:51
teatwo left
19:37
jgaz joined
20:10
gfldex left,
sivoais left,
nicole left
20:11
gfldex joined,
sivoais joined,
nicole joined
20:17
sivoais left
20:18
sivoais joined
20:24
jgaz left
22:29
QhpAptyj9hj0RQwM joined
23:14
QhpAptyj9hj0RQwM left
|
|||