guifa steveid: they function slightly differently. raku and perl chomp both generally remove a newline, but there are subtle differences. 00:03
perl::chomp removes all trailing instances of $/ (or $INPUT_RECORD_SEPARATOR), which is by default a newline (which newline, I'm not sure off the top of my head, tbh). it returns the number of characters removed
raku::chomp removes, if present, a single instance of anything with a property of newline (LF, VT, FF, CR, CR+LF, NEL, LS, PS), and returns the string with it removed 00:07
if you're porting code, that difference may result in bugs
stevied ok, gotcha. makes sense. 01:36
02:33 [Coke] left 02:39 [Coke] joined 02:55 [Coke]_ joined 02:56 melezhik joined 02:57 [Coke] left 03:12 melezhik left 04:18 destroycomputers left
RoM Thank you very much for the two hints, SmokeMachine and guifa. I will test the two modules. 10:27
13:14 [Coke]_ is now known as [Coke] 13:38 destroycomputers joined
stevied what do you call the asterisk in a signature like this: `multi odd-or-even(Int $i where * %% 2) { say "even" };` 15:03
a "placeholder" maybe?
[Coke] It's a "Whatever" 15:08
stevied seriuosly? 15:11
Anton Antonov @stevied#8273 How is this surprising?! 🙂
stevied guess so:
Anton Antonov A fair warning -- there are some other whatevers... 15:13
[Coke] You can read it as "where whatever you get is divisible by 2" 15:14
but it's a Whatever/WhateverCode under the covers, yes.
stevied crazy stuff 15:15
gfldex m:``` 15:38
my \w = * %% 2;
.say for w.&{ [.WHAT, .^mro, .signature] };
shift-eleven heya, if I wanted to find the implementation of a certain method in raku (namely `succ`) which repo should I be browsing through 15:56
lizmat rakudo/rakudo 16:02
shift-eleven gotcha thanks 16:03
16:05 destroycomputers left
stevied can someone please shed some light on this weirdness on the left-hand side of the assignemnt: `$ = :($a, @b); ` 16:05
what is `$` doing there all alone? 16:06
lizmat yeah, that *is* weirdness that I hoped TimToady would not go into 16:07
it's the nameless state variable 16:08
m: sub a() { say $++ }; a for ^5
camelia 0
stevied TimToady?
lizmat Larry Wall's nick 16:09
a pun on TIMTOWTDI
stevied so it's the same as $_ ?
lizmat no
stevied gotcha
lizmat $_ is *not* a state variable
m: sub a() { state $a++ }; a for ^5
camelia ( no output )
lizmat m: sub a() { say state $a++ }; a for ^5
camelia 0
lizmat m: sub a() { say $_++ }; a for ^5 16:10
camelia 0
stevied yeah, familiar with state variables, somewhat (don't use them much) 16:11
I guess a better question then is why would assign anything to `$`? 16:13
MasterDuke that might put the statement in non-sink context, so maybe to silence a warning 16:16
stevied "non-sink" context? I guess I better put this question off until I get more familiar with raku 🙂 16:17
MasterDuke sink is kind of like void 16:18
m: 1
camelia WARNINGS for <tmp>:
Useless use of constant integer 1 in sink context (line 1)
MasterDuke that `1` isn't being used, so it's in sink context (sort of, i wouldn't say i'm 100% versed on exactly what is/isn't sink and all it's properties) 16:19
lizmat m: class A { method sink() { say "sunk" } }; A 16:23
camelia WARNINGS for <tmp>:
Useless use of constant value A in sink context (line 1)
lizmat m: class A { method sink() { say "sunk" } };
camelia sunk
lizmat basically, any defined object that is in "void" context, has its "sink" method called on it
which generally is a no-op 16:24
stevied I don't get a warning with just `:($a, @b)` on a line by itself 16:25
lizmat m: :($a,@b)
camelia ( no output )
lizmat he, interesting 16:26
m: dd :($a,@b)
camelia :($a, @b)
lizmat m: dd (:($a,@b)).^name
camelia "Signature"
lizmat I guess Signatures are exempt from thst
stevied maybe that assignment to `$` should be removed from docs to prevents newbs like me from getting distracted? 16:28
lizmat yeah... where did you see that ?
stevied 16:29
seems like it would be more clear if the signature object was in the context of an ordinary subroutine or something 16:31
docs also have this mystery: `sub one-arg (@) { }` 16:38
so the sub will only take an array. but it doesn't explain that anywhere I can see 16:39
how do you access such an argument in the function?
MasterDuke anonymous array variable. means the sub is required to be passed an array, but it doesn't do anything with it 16:40
16:40 Flwyd joined
stevied what is the use case for something like that? 16:40
MasterDuke by itself probably isn't very useful, but you might see things like that with multis (and usually other parameters that it does use)
stevied I could see it with multis if you use {*} 16:42
I guess you would do that with a proto, though
MasterDuke m: multi sub foo(Int $a, @) { say "i care about the scalar '$a'" }; multi sub foo($, @b) { say "i care about the array '@b'" }; foo(1, <a b c>); foo("a", <b c d>) 16:43
camelia i care about the scalar '1'
i care about the array '@b'
MasterDuke m: multi sub foo(Int $a, @) { say "i care about the scalar '$a'" }; multi sub foo($, @b) { say "i care about the array '@b[]'" }; foo(1, <a b c>); foo("a", <b c d>)
camelia i care about the scalar '1'
i care about the array 'b c d'
MasterDuke ^^^ contrived example, but that sort of thing 16:44
stevied ok
gfldex @stevied#8273 One can do crazy things with `sink`, see:
stevied I would just say then that that should be documented somewhere in I don't think it's mentioned, but I could be wrong 16:46
@gfldex#8222 that's way above my ability to wrap my head around. jesus 16:50
16:53 [Coke] left 16:54 [Coke] joined 17:04 codesections left, codesections joined
I'm getting the sense if you get good at Raku, every other language will just look like a toy. Is that accurate? 17:09
17:12 destroycomputers joined
guifa MasterDuke it can also be used in destructuring in a signature. Imagine something like `sub foo( |c ($x, @, @, $z) { … }` where you want to pull out the first and fourth, and will eventually pass the capture through 17:52
gfldex @stevied#8273 I'm not so sure about that. There are plenty of reason why one would want to write code for a micro controller. Raku will not teach you about memory management or optimising down to individual machine instructions. At the other hand, we got really good OOP support and fairly good functional stuff. 17:57
stevied yeah, I was thinking more along the lines of comparing to higher level languages 17:58
18:11 destroycomputers left 18:13 Flwyd left 18:14 Flwyd joined, MasterDuke left 18:24 destroycomputers joined 19:03 discord-raku-bot left 19:04 discord-raku-bot joined 19:32 MasterDuke joined