🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | 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 8 June 2022. |
|||
00:06
reportable6 left
00:09
reportable6 joined
01:09
committable6 left,
reportable6 left,
bloatable6 left,
statisfiable6 left,
nativecallable6 left,
notable6 left,
unicodable6 left,
bisectable6 left,
benchable6 left,
greppable6 left,
quotable6 left,
linkable6 left,
releasable6 left,
coverable6 left,
tellable6 left,
sourceable6 left,
shareable6 left,
evalable6 left,
notable6 joined,
bisectable6 joined,
statisfiable6 joined
01:10
sourceable6 joined,
quotable6 joined,
evalable6 joined,
tellable6 joined,
greppable6 joined,
reportable6 joined,
nativecallable6 joined
01:11
bloatable6 joined,
benchable6 joined,
unicodable6 joined
01:12
shareable6 joined,
coverable6 joined,
linkable6 joined,
releasable6 joined,
committable6 joined
01:34
swaggboi left
02:07
frost joined
03:07
bisectable6 left,
tellable6 left,
nativecallable6 left,
shareable6 left,
coverable6 left,
linkable6 left,
sourceable6 left,
quotable6 left,
unicodable6 left,
notable6 left,
bloatable6 left,
benchable6 left,
greppable6 left,
evalable6 left,
statisfiable6 left,
reportable6 left,
committable6 left,
releasable6 left,
bisectable6 joined,
unicodable6 joined,
reportable6 joined
03:08
quotable6 joined,
tellable6 joined,
sourceable6 joined,
shareable6 joined,
evalable6 joined,
benchable6 joined,
greppable6 joined,
committable6 joined,
nativecallable6 joined,
linkable6 joined
03:09
statisfiable6 joined,
notable6 joined,
coverable6 joined
03:10
releasable6 joined,
bloatable6 joined
04:10
unicodable6 left,
coverable6 left,
committable6 left,
quotable6 left,
linkable6 left,
benchable6 left,
greppable6 left,
bloatable6 left,
shareable6 left,
evalable6 left,
nativecallable6 left,
sourceable6 left,
releasable6 left,
statisfiable6 left,
reportable6 left,
tellable6 left,
notable6 left,
bisectable6 left,
evalable6 joined,
bloatable6 joined,
unicodable6 joined,
coverable6 joined,
quotable6 joined
04:11
bisectable6 joined,
sourceable6 joined,
nativecallable6 joined
04:12
benchable6 joined,
tellable6 joined,
statisfiable6 joined
04:13
releasable6 joined,
greppable6 joined,
linkable6 joined,
shareable6 joined,
reportable6 joined,
committable6 joined,
notable6 joined
|
|||
guifa | You know what would actually make slangs much easier to write? | 04:37 | |
private tokens | |||
oh wait, private methods compose (I feel like they shouldn't?) | 04:39 | ||
I can my scope it, but stubbing doesn't really work with tokens | 05:01 | ||
05:13
linkable6 left,
evalable6 left
05:14
linkable6 joined
05:15
evalable6 joined
06:07
reportable6 left
06:08
reportable6 joined
|
|||
moritz | private methods (in roles, I assume) must compose; you never call anything on a role, but on a role applied to a class. If they didn't compose, you'd never be able to call them | 07:01 | |
07:04
Sgeo left
08:04
evalable6 left,
linkable6 left
08:05
evalable6 joined
08:06
linkable6 joined
08:07
sena_kun joined
08:22
Sankalp left,
Sankalp joined
09:29
sena_kun left
09:30
linkable6 left
09:31
linkable6 joined
09:35
jaguart joined
09:37
sena_kun joined,
sena_kun left
10:15
linkable6 left
10:16
linkable6 joined
10:52
kaskal left
10:58
kaskal joined
11:34
kaskal left
11:45
Sankalp left
11:46
Sankalp joined
11:47
kaskal joined
|
|||
guifa_ | moritz yeah, that makes sense. I'm just annoyed at having to namespace my tokens in slangs, that's all :-) | 11:54 | |
12:07
reportable6 left
12:08
reportable6 joined
12:18
kaskal left
12:22
kaskal joined
12:30
zmoment_ left
13:07
Colere left
13:08
Colere joined
13:10
Furor joined
13:13
Colere left
13:19
frost left
13:31
Furor is now known as Colere
14:31
evalable6 left
14:34
evalable6 joined
15:05
Sgeo joined
15:12
Guest48 joined
15:13
jaguart left
|
|||
SmokeMachine | lizmat: yes, vim accepts `-q`... github.com/lizmat/Edit-Files/pull/1 | 15:36 | |
lizmat | s/vim/nvim/ I assume :-) | 15:38 | |
SmokeMachine | yes :) | ||
15:51
Guest48 left
16:03
oliphant joined
|
|||
oliphant | Hello whats an assertion way in Raku? like the assert or static_assert in some other languagse | 16:05 | |
16:10
FehmiD joined
16:11
saint- joined,
FehmiD left
|
|||
Nemokosch | are you writing test cases? | 16:12 | |
oliphant | no writing a code where some place asserted to be unreachable | 16:13 | |
or some mathematical logic satisfied | 16:14 | ||
moritz | die "this should never be reached because of $reason" | 16:19 | |
there's actually a built-in always-fail assertion, prefix:<!!!!> | |||
m: !!! "foo" | |||
camelia | foo in block <unit> at <tmp> line 1 |
||
oliphant | So did it fail? | 16:21 | |
moritz | yes | ||
m: !!! "foo"; say "never reached" | |||
camelia | foo in block <unit> at <tmp> line 1 |
||
oliphant | oh | 16:22 | |
moritz | to answer the original question, raku has a lot of constructs that assertions are often used for | ||
16:22
Tirifto left
|
|||
moritz | these include: subtypes with code checks, PRE and POST conditions for routines, and code checks in signatures | 16:22 | |
m: subset Positive of Int where { $_ > 0 }; my Positive $x = 42; say "alive"; $x = -4; say "no more alive" | 16:23 | ||
camelia | alive Type check failed in assignment to $x; expected Positive but got Int (-4) in block <unit> at <tmp> line 1 |
||
moritz | m: sub factors(Int $x where !.is-prime) { 42 }; factors(13) | ||
camelia | Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Int (13) in sub factors at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
moritz | m: sub increment(Numeric $x) { POST $_ > $x; return $x +1 }; increment 4 | 16:24 | |
camelia | ( no output ) | ||
moritz | m: sub increment(Numeric $x) { POST $_ > $x; return $x - 1 }; increment 4 | ||
camelia | Postcondition '$_ > $x' failed in sub increment at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
moritz | that said, I don't think there's an explicit assert | 16:25 | |
lizmat | m: sub assert($condition, $message) { die $message unless $condition }; assert 42 < 666, 'foo'; assert 42 > 666, 'bar' | 16:27 | |
camelia | bar in sub assert at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
16:27
Tirifto joined
|
|||
lizmat | oliphant: ^^ something like that ? | 16:27 | |
moritz | it's easy to make one as lizmat demonstrated, though it does evaluate the message even if the condition is true | ||
once RakuAST lands, it'll probably be easy to make a higher-quality one | 16:28 | ||
oliphant | wow POST | ||
Whats $_ in POSt being? | |||
Im familiar with $_ | |||
Asking its topic there | |||
lizmat | m: { POST say "POST: $_"; 42 } | 16:29 | |
camelia | WARNINGS for <tmp>: POST: 42 Useless use of constant integer 42 in sink context (line 1) |
||
moritz | oliphant: the return value of the routine | ||
lizmat | m: my $b := { POST say "POST: $_"; 42 }; $b() | ||
camelia | POST: 42 | ||
lizmat | m: sub foo() { POST say "POST: $_"; 42 }; foo | ||
camelia | POST: 42 | ||
oliphant | thank you Raku persons | 16:30 | |
My other query is difference of fail and die | |||
lizmat | you're welcome :-) | ||
oliphant | Above used die for example | ||
But why not fail? | 16:31 | ||
Its not cathchable? | |||
(the die) | |||
moritz | fail is a bit softer than die | 16:32 | |
oliphant | When should i fail insteed | ||
moritz | fail returns an exception wrapped in a timebomb, that explodes if you use it like a regular value, but if you check it for .defined first, it's good | ||
lizmat | m: sub foo() { fail "bar" }; my $a = foo; say "still alive"; my $b = $a | ||
camelia | still alive | ||
lizmat | m: sub foo() { fail "bar" }; my $a = foo; say "still alive"; my $b = $a + 2 | 16:33 | |
camelia | still alive bar in sub foo at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
moritz | this enables routines that both throw an exception if nobody checks it, but doesn't need exceptions if the user prefers it that way. More magical, supposedly better for highly parallel computations | ||
it's a bit too magical for my tastes, so I go straight for die(), usually. | 16:34 | ||
YMMV | |||
oliphant | oo timebomb 😂 i understand the diff | 16:35 | |
i need to see more code of people where to use where not i say | 16:36 | ||
thanking again | |||
16:38
oliphant left
|
|||
moritz | my pleasure | 16:38 | |
17:38
linkable6 left,
evalable6 left,
linkable6 joined
17:41
evalable6 joined
17:46
kaskal left
17:51
sena_kun joined
17:52
kaskal joined
18:07
reportable6 left
18:09
reportable6 joined
|
|||
Nemokosch | what is needed for a new version of a module to be published? | 18:10 | |
I mean, my PR to Terminal::Getpass got merged - is something additional needed so that the new version gets available? | |||
moritz | the maintainer needs to make a release and upload it to whatever ecosystem is used | 18:14 | |
Nemokosch | 👍 | 18:15 | |
18:39
Guest48 joined,
Guest48 left
18:53
Xliff joined
|
|||
Xliff | \o | 18:53 | |
m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; | |||
camelia | False | ||
Xliff | m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; &b; | ||
camelia | WARNINGS for <tmp>: False Useless use of &b in sink context (line 1) |
||
Xliff | m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; &b.say; | ||
camelia | False &__PRIMED_ANON |
||
Xliff | m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; &b().say; | 18:54 | |
camelia | False [1 2] True |
||
Xliff | m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; &b(); | ||
camelia | False [1 2] |
||
Xliff | m: sub a (*@a) { @a.say }; my &b = &a.assuming(1, 2); &b.is-wrapped.say; &b(); &b.name.say | ||
camelia | False [1 2] __PRIMED_ANON |
||
Xliff | OK, If I have &b as above, is there any way to get back the reference to the original callable? | 18:55 | |
19:24
guifa left
19:45
guifa joined,
guifa left
19:50
m_athias left,
nine left,
nine joined
19:51
m_athias joined
19:52
Guest23 joined,
Guest23 left
20:09
sena_kun left
20:10
sena_kun joined
21:04
melezhik joined
|
|||
melezhik | o/ | 21:04 | |
What's up | |||
Nemokosch | hello | 21:10 | |
as time passes, the more urgent it seems for me to document returned containers better | |||
21:10
Nemokosch joined
|
|||
Nemokosch | let me illustrate | 21:10 | |
21:10
melezhik left
|
|||
Nemokosch | m: my @flat-array = <the name is bond bon bond>; @flat-array.batch(2)[1;1] = 'short'; dd @flat-array; | 21:11 | |
camelia | Array @flat-array = ["the", "name", "is", "short", "bon", "bond"] | ||
21:11
Nemokosch left
|
|||
Nemokosch | this is unbelievably cool - but how should one expect it? | 21:12 | |
21:20
habere-et-disper joined
|
|||
habere-et-disper | How do you take the odd or even elements of a list? | 21:20 | |
m: say (10,11,12,13,14,15,16,17,18,19,20).grep( *.keys %% 2 ) | |||
camelia | () | ||
lizmat | m: say (10,11,12,13,14,15,16,17,18,19,20).grep({ $++ %% 2 }) | 21:22 | |
camelia | (10 12 14 16 18 20) | ||
lizmat | m: say (10,11,12,13,14,15,16,17,18,19,20).grep({ ++$ %% 2 }) | ||
camelia | (11 13 15 17 19) | ||
p6steve | m: say (10,11,12,13,14,15,16,17,18,19,20).grep( {$_ %% 2} ) | ||
Nemokosch | oh for some reason I thought indices | ||
liz also thought indices, it's fine then 😄 | |||
lizmat | .oO( the magic of the nameless state variable |
||
) | |||
Nemokosch | the nameless state variable bit me this week | 21:23 | |
lizmat | habere-et-disper: I interpreted it as odd or even *elements*, not the values | ||
Nemokosch | don't use it with recursive functions... | ||
lizmat | yeah | ||
true | |||
m: say (10,11,12,13,14,15,16,17,18,19,20).grep(:2nd) # wonder if that would make sense | 21:24 | ||
camelia | Cannot resolve caller grep(List:D: :nd(Int)); none of these signatures matches: ($: Bool:D $t, *%_) ($: Mu $t, *%_) in block <unit> at <tmp> line 1 |
||
Nemokosch | categorize can also work, to get both | 21:25 | |
21:25
Nemokosch joined
|
|||
Nemokosch | (10..20).categorize({ $++ % 2 }) | 21:26 | |
oops | |||
m: dd (10..20).categorize({ $++ % 2 }) | |||
camelia | (my Any %{Mu} = 0 => $[10, 12, 14, 16, 18, 20], 1 => $[11, 13, 15, 17, 19]) | ||
p6steve | (10..20).classify({$_ %% 2}) | 21:27 | |
{False => [11 13 15 17 19], True => [10 12 14 16 18 20]} | |||
habere-et-disper | lizmat Thank you -- I did want the indices! :) | ||
Nemokosch | right, categorize is the one that can overlap, classify is the one that cannot | 21:28 | |
p6steve | (10..20).keys.classify({$_ %% 2}) | 21:29 | |
{False => [1 3 5 7 9], True => [0 2 4 6 8 10]} | |||
Nemokosch | of course rotor can also be useful to a certain degree | 21:30 | |
p6steve | (10..20).keys.categorize(* %% 2) | ||
Nemokosch | m: dd (10..20).rotor(1 => 1) | 21:31 | |
camelia | ((10,), (12,), (14,), (16,), (18,), (20,)).Seq | ||
p6steve | {False => [1 3 5 7 9], True => [0 2 4 6 8 10]} | ||
Nemokosch | rotor emits one-element lists though | ||
lizmat | and nowadays, there's also snip! | 21:32 | |
Nemokosch | what is that? | ||
lizmat | m: dd (^10).snip( * < 5 ) | ||
camelia | No such method 'snip' for invocant of type 'Range'. Did you mean any of these: 'Slip', 'skip', 'flip', 'sin'? in block <unit> at <tmp> line 1 |
||
p6steve | huh? | ||
lizmat | meh | ||
m: dd (0,1,2,3,4,5,6,7,8,9).snip( * < 5 ) | 21:33 | ||
camelia | No such method 'snip' for invocant of type 'List'. Did you mean any of these: 'Slip', 'skip', 'flip', 'sin'? in block <unit> at <tmp> line 1 |
||
lizmat | hmmm | ||
Nemokosch | what version? | ||
I also don't have it with 2022.04 | |||
lizmat | m: dd Compiler.new.version | 21:34 | |
camelia | v2022.06.55.g.7.ec.4.b.10.d.7 | ||
SmokeMachine | m: my &incr := * + 1; 41 ==> incr() ==> say() #`(this works...); [==>] 41, incr(), say() # should this work? | ||
camelia | Potential difficulties: Useless use of [==>] in sink context at <tmp>:1 ------> ==> incr() ==> say() #`(this works...); ⏏[==>] 41, incr(), say() # should this wo 42 Cannot resolve caller METAOP_REDUCE_LIST(VMNull); none … |
||
SmokeMachine | m: my &incr := * + 1; 41 ==> incr() ==> say() # this works... | ||
camelia | 42 | ||
lizmat | aah... | ||
SmokeMachine | m: my &incr := * + 1; [==>] 41, incr(), say() # should this work? | ||
camelia | Potential difficulties: Useless use of [==>] in sink context at <tmp>:1 ------> my &incr := * + 1; ⏏[==>] 41, incr(), say() # should this wo Cannot resolve caller METAOP_REDUCE_LIST(VMNull); none of these signatures match… |
||
lizmat | m: use v6.e; dd (^10).snip( * < 5 ) | ||
camelia | ===SORRY!=== Error while compiling <tmp> Raku v6.e requires PREVIEW modifier at <tmp>:1 ------> use v6.e⏏; dd (^10).snip( * < 5 ) |
||
lizmat | m: use v6.*; dd (^10).snip( * < 5 ) | ||
camelia | ((0, 1, 2, 3, 4), (5, 6, 7, 8, 9)).Seq | ||
lizmat | *phew* only on 6.e :-) | 21:35 | |
p6steve | oh there was a recent SO on that - cool | ||
stackoverflow.com/questions/728094...n-function | 21:37 | ||
is snip === nsap | |||
/snip/span/ | |||
btw why not call it span? | |||
habere-et-disper | .grep(:2nd) is rather css like | 21:38 | |
lizmat | m: use v6.*; dd (^20).snip( * < 5, * < 10 ) # p6steve: can have more than one condition, and span cannot | ||
camelia | ((0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13, 14, 15, 16, 17, 18, 19)).Seq | ||
Nemokosch | also, any idea how to be more explicit about the containers? Namely that functions usually treat their arguments as raw | 21:39 | |
21:39
sena_kun left
|
|||
lizmat | afk& | 21:41 | |
Nemokosch | actually this also means that some things _only work_ with @, which is a whole new perspective for me | ||
p6steve | lizmat: tx! | 21:43 | |
habere-et-disper | Is there a list of deprecations? I want to ask the REPL if possible. | 21:44 | |
21:45
Nemokosch left
|
|||
Nemokosch | the REPL about deprecations? | 21:45 | |
21:45
Nemokosch joined
|
|||
gfldex | habere-et-disper: There is no complete list but since they are introduced by a trait, you could wire Rakudo up to show them all. | 21:47 | |
habere-et-disper | gfldex Thank you. I don't know how to do this but will investigate. | 21:56 | |
22:02
habere-et-disper left
22:03
Nemokosch left
|
|||
SmokeMachine | m: use v6.*; dd (^20).snip( |^Inf .map: { { $^a * 5 > $^B } } ) | 22:03 | |
camelia | ===SORRY!=== Error while compiling <tmp> Unsupported use of $^B variable at <tmp>:1 ------> ^20).snip( |^Inf .map: { { $^a * 5 > $^B⏏ } } ) |
||
22:06
Tirifto left
|
|||
SmokeMachine | m: use v6.*; dd (^20).snip( |^Inf .map: { { $^a * 5 > $^b } } ) | 22:06 | |
camelia | Too few positionals passed; expected 2 arguments but got 0 in block at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
SmokeMachine | m: use v6.*; dd (^20).snip( |^Inf .map: { * * 5 > * } ) | 22:07 | |
camelia | ===SORRY!=== Error while compiling <tmp> Malformed double closure; WhateverCode is already a closure without curlies, so either remove the curlies or use valid parameter syntax instead of * at <tmp>:1 ------> dd (^20).snip( |^Inf .map: {… |
||
SmokeMachine | m: use v6.*; dd (^20).snip( |^Inf .map: { (* * 5 > *) } ) | ||
camelia | MoarVM panic: Memory allocation failed; could not allocate 67462656 bytes | ||
22:23
euandreh joined
22:24
Tirifto joined
22:46
Tirifto left
22:51
discord-raku-bot left,
discord-raku-bot joined
22:55
discord-raku-bot left,
discord-raku-bot joined
23:00
discord-raku-bot left,
discord-raku-bot joined,
Tirifto joined
|
|||
lizmat | SmokeMachine:hmmm.. interesting.. :-) | 23:02 | |
care to make an issue for that ? | |||
23:04
discord-raku-bot left,
discord-raku-bot joined
|
|||
El_Che | hi lizmat | 23:05 | |
23:06
Tirifto left
|
|||
lizmat | El_Che: hi, but going afk for the night & | 23:07 | |
El_Che | :) | 23:13 | |
23:40
gugod left
|