🦋 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.
vrurg SmokeMachine: nah, my mistake. M1 yet. 00:12
ToddAndMargo Newbie bitwise buffer question:  what am I doing from with this bitwise OR? 08:49
[6] > say (buf8.new(0x5D) +| buf8.new(0x00));
1
evalable6 WARNINGS for /tmp/bpYSjCc3aL:
1
Useless use of ">" in expression "[6] > say (buf8.new(0x5D) +| buf8.new(0x00))" in sink context (line 1)
ToddAndMargo [6] > say (buf8.new(0x5D) +| buf8.new(0xFF));
1
evalable6 WARNINGS for /tmp/DAqVjPotd6:
1
Useless use of ">" in expression "[6] > say (buf8.new(0x5D) +| buf8.new(0xFF))" in sink context (line 1)
dakkar why are you comparing a 1-element array to the result of `say`?
in other words, why are you starting with `[6] > `?
also, buf8 is a class, so the result of buf8.new is an object 08:51
not a number
bitwise ops don't make much sense for objects…
ToddAndMargo I am trying to show examples of buffers and bitwise operations.  I am starting with OR.  Yo know what.  My bad.  REPL will show me the result.  No need for say. 08:54
dakkar I'm pretty sure you can not do bitwise ops on bufs 08:55
ToddAndMargo I do XOR and cells all the time 08:56
dakkar interesting!
can you show me some expressions that work? because I'm not seeing it 08:57
ToddAndMargo [15] > my buf8 $i= buf8.new(0x5D, 0xAE); 08:59
Buf[uint8]:0x<5D AE>
[16] > my buf8 $j= buf8.new(0xAB, 0xCD);
Buf[uint8]:0x<AB CD>
[17] > $i[0] += $j[0];
8
[18] > $i[1] += $j[1];
123
dakkar aah, but you're not operating on the buf!
you're operating on the elements of the buf 09:00
which are numbers
ToddAndMargo [19] > $i[0] +^ $j[0];
163
[20] > $i[1] +^ $j[1];
182
dakkar yes, those are elements (see the square-bracked subscript?)
ToddAndMargo just the cells in the buffer.  I can't get away with it on the entire buffer as I can with an integer.  This manes sense, since a buffer is an array of bytes and anot a data structure like an integer 09:01
Thank you .  I realize what I am doing wrong now. 09:02
SmokeMachine m: say buf8.new(0x5D).head +| buf8.new(0xFF).head
camelia 255
SmokeMachine m: say buf8.new: buf8.new(0x5D).head +| buf8.new(0xFF).head 09:03
camelia Buf[uint8]:0x<FF>
ToddAndMargo this is what I wrote up on my Keeper document (,odt) on buffers: 09:07
Bitwise Operations:
Please note that a buffer is NOT a data structure other than an “array of (raw) bytes”. You can only do bit wise operations on a single cell at a time.
> my buf8 $i= buf8.new(0x5D);
> my buf8 $j= buf8.new(0xAB);
Bitwise AND:
> $i[1] +& $j[1];
0
and so on and so forth
lizmat Note that you can iterator over Bufs: 09:36
m: my $b = Buf.new(1,2,3); $_++ for $b[]; dd $b
camelia Buf $b = Buf.new(2,3,4)
Nemokosch japhb: you are the author of Terminal::LineEditor, right? 09:53
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/06/20/2022-...will-raku/ 12:02
frost lizmat++, in the news, the code `say @a; say @b'` has an extra `'` 13:50
japhb Yes, I am the author of Terminal::LineEditor. 14:29
(For some reason, irsii didn't highlight my nick when sent via the Discord relay. Dunno why.) 14:30
uzl[m] Will the in-person presentations be recorded? 15:29
lizmat++
I am liking these `Did You Know?`s haha. Quite informative! 15:31
uzl[m] weekly: lobste.rs/s/hpxa66/make_raku_progr...e_familiar 15:33
notable6 uzl[m], Noted! (weekly)
perryprog Raku mentioned on the HN's as well: 15:51
weekly: news.ycombinator.com/item?id=31797918
notable6 perryprog, Noted! (weekly)
perryprog just realized lizmat was the one who posted it
Voldenet > :(@b, @a) := (@a, @b); 15:56
that's neat, but it doesn't compose well 16:03
m: my @a = <1 2 3>; my @b = <a b c>; :(@b, @a) := (@a, @b); say @a, @b
camelia [a b c][1 2 3]
Voldenet m: my @a = <1 2 3>; my @b = <a b c>; if True { :(@b, @a) := (@a, @b); }; say @a, @b 16:04
camelia Lexical with name '@b' does not exist in this frame
in block <unit> at <tmp> line 1
Voldenet m: my @a = <1 2 3>; my @b = <a b c>; if True { my @t := @b; @b := @a; @a := @t; }; say @a, @b 16:05
camelia [a b c][1 2 3]
Voldenet "dumb code" works
andinus are there examples of Persistent session management with Cro on the web? 16:13
apart from the official docs: cro.services/docs/http-auth-and-se...management
SmokeMachine andinus: github.com/FCO/Cro-HTTP-Session-Red 16:24
andinus thanks 16:26
SmokeMachine (That can be very useful if you are using Red… 16:29
Voldenet also github.com/croservices/cro-http-session-pg
vrurg I wonder if it would be ok to transfer JSON::Unmarshal to community modules. It seems to be long abandoned. And tadzik is not around for nearly a year. 17:14
lizmat frost: thanks for the headsup, fixed 17:24
tellable6 lizmat, I'll pass your message to frost
vrurg lizmat: what do you think about JSON::Unmarshall? 17:28
SmokeMachine vrurg: I don't think that's abandoned... recently we got the opt-in update to JSON::Marshal and JSON::Class 17:34
vrurg SmokeMachine: Unmarshall is a separate module by tadzik.
SmokeMachine oh, ok... sorry... 17:35
Voldenet original author is on libera, so you can just ask ┐(´~`;)┌
vrurg SmokeMachine: try to unmarshall class Foo is JSON::Class { has CustomClass:D %.cc; }
Voldenet: we're on libera, ain't we? ;) 17:36
SmokeMachine Custom class needs JSON::Class as well?
vrurg SmokeMachine: Yes, but it doesn't matter. Perhaps Int:D or Str:D would do as well.
SmokeMachine oh! :D is the problem... 17:37
?
Voldenet …I think so, all of my configs say "freenode" because I only changed server names and certs :P
vrurg SmokeMachine: aha. The module doesn't care about nominalizables. 17:38
Somehome coercion doesn't break it. It's a miracle. :)
SmokeMachine (talking about marshalling... I really miss a was to serialise an object and the data includes the class name, to be possible to do something like: `$representation.deserialise` and that would create the object) 17:39
vrurg *Somehow
SmokeMachine: Implement! :D
lucs Can I have a MAIN-like method in a module, that is, its args would be read from the command line and parsed in the same way MAIN does? 「▸ raku -e 'use Foo; Foo.MAIN' -a=42」 17:40
SmokeMachine vrurg: I was implementing it... but Red drains all my free time... 17:42
vrurg lucs: try looking into Rakudo sources, src/core.c/Main.pm6. Though be careful, it's undocumented.
SmokeMachine: I know. That's where the smile comes from.
SmokeMachine: BTW, I was very much missing oracle driver. But neither had time to implement it, nor to wait for implementation. 17:43
SmokeMachine vrurg: I still have to find some time to finish the MySQL driver: github.com/FCO/Red-Driver-MySQL 17:45
vrurg You need more people. The project is growing beyond single-person maintainability. Wishful thinking, though. 17:46
SmokeMachine vrurg: yes, more people helping would help a lot! That Squishathon with people was helping Red was great, for example... 17:48
lucs vrurg: Thanks 17:49
SmokeMachine And I really want to release the first stable version as soon as possible (github.com/FCO/Red/issues/470#issu...786132637) 17:51
vrurg SmokeMachine: crossing my fingers 17:52
vrurg is afk. Too much work too. :)
japhb lucs: MAIN can be exported as a multi from modules. That's how many App::* modules work (including all of mine, both public and private). I know that's not the same as a method, but you could also declare them `our` and access them through stashes instead, if that's your wont. 18:08
lucs japhb: Interesting. I'll look into that, thanks. 18:14
lucs japhb: Um, would you happen to have a link to one of those public App::* modules? 18:30
japhb Give me a sec 18:34
github.com/Raku-MUGS/MUGS-UI-CLI/b...kumod#L360 18:35
Also shows partial override of USAGE generation 18:36
guifa is about to die
Moving went waaaay slower than expected this weekend, and now I've only got like 24 hours to finish writing my talks for P&RC and yeah.... no where close :-( 18:37
lucs japhb: Thanks a bunch. 18:38
japhb Sure, no problem! :-) 18:39
guifa: Ackpth! Good luck! 18:40
guifa japhb thanks. I actually just realized my first talk isn't until Thursday so… yay. but just means I'll be antisocial on Wednesday at the conference lol 18:41
sena_kun wow, the conference looks lively 19:11
guifa, good luck with the prep! 19:12
drakonis oh, it starts tomorrow, right? 19:19
guifa drakonis yeah, tomorrow there's some of the typical preconference stuff (classes, etc) and Wednesday starts the talks 20:16
guifa came up with his advent day post for this year
making a regex for email
but like, actually following the RFC to the letter, with no false positives or negatives. is actually possible in Raku 20:17
perryprog is that even possible 21:42
with POSIX regex 21:43
Nemokosch Voldenet: no question that you can swap two variables the same way you could in C, no need for binding even :D 21:58
tellable6 2022-06-15T14:17:06Z #raku <SmokeMachine> Nemokosch: I think it's possible: github.com/FCO/GccJit
Nemokosch the thing is, it would work fine with $variables
Nemokosch m: dd $(1, 2; 5, 6) 22:31
Nemokosch m: dd $(1, 2; 5, 6) 22:32
camelia WARNINGS for <tmp>:
Useless use of constant integer 2 in sink context (lines 1, 1)
Useless use of constant integer 1 in sink context (lines 1, 1)
$(5, 6)
Nemokosch the question is: what happened here?
m: dd (1, 2; 5, 6) 22:33
camelia ((1, 2), (5, 6))
Nemokosch where did (1, 2) go? 😅
gfldex Does a multi-dim scalar make sense? Where should it bind the 2nd dimension to? 22:39
Nemokosch it makes exactly as much sense as $((1, 2), (5, 6)) 22:54
which does exist
also, trust me it's pretty useful when you do matrix algebra
the more I use Raku, the more I grow to realize @ was created to simply annoy coders 23:29
drakonis if raku gets a new major version 23:34
delete sigils
alternatively, idk
Nemokosch if you have a multi-dimensional array 23:35
$a[0] will contain a proper list
but @a[0] will contain a scalar!
whyyyyy
with no particular hints why this should happen, and how to opt out
and you know what makes it so painful? that Z and X and stuff like this will always bring that implicit Scalarness 23:37
even though that's not even needed for them since they aren't recursive anyway
if I want the elements to be treated as scalars, I will say it!
Nemokosch here, see... 23:38
m: my @a = (1, 2; 3, 4); dd @a; dd @a[0];
camelia Array @a = [(1, 2), (3, 4)]
List @a = $(1, 2)
Nemokosch the Scalar appears out of nowhere, for hell's sake
m: my $a = (1, 2; 3, 4); dd $a; dd $a[0]; 23:39
camelia List $a = $((1, 2), (3, 4))
(1, 2)
Nemokosch but if I just take the multidimensional list itself as a scalar, magic: the elements will stay proper 23:40
at this point I'm considering a style where I never use @variables and prefix my scalars if need be 23:41
probably there won't be much need because
m: my $a = (1, 2; 3, 4); dd $a[]; dd $a[0]; 23:42
camelia ((1, 2), (3, 4))
(1, 2)
Nemokosch What other reason would there be to use the @ sigil? 23:43
rir @Nemokosch, I not really equipped to give you a clear full answer; I have never used ';' as a separator in an array. 23:49
But if you are looking for shaped arrays those are not yet supported. 23:51
Beyond that I am not sure if you are lost or just unhappy with the actions or both. 23:52
Nemokosch I just came across this while trying to compose a call that takes me closer to the Kronecker product
Honestly, the situation is a bit awkward 23:53
drakonis Nemokosch: at least raku doesnt have perl's contexts
i hear it is a much bigger problem there
Nemokosch I do find $(1, 2; 5, 6) bug-worthy. It's the least to expect it to work consistently, once it's promoted as a literal syntax for multi-dimensional arrays. 23:54
However, it's a minor nuisance; one could live without this syntax, after all
@variables never cease to disappoint, on the other hand
And I suspect that's not really a bug or whatever 23:55
It's just design that leaves me clueless who thought this abstraction was a good idea and why
rir I don't have that math. Instead of contexts Raku has containers. I thought context was the key part of Perl that made it better than most scripting languages.
Better meaning a little higher. 23:56
Nemokosch Really, even in this case where it's clear as water that I do want a "positional", a (multi-dimensional) list in particular
$ works way more predictable and flexible 23:57
rir If you want to understand Raku re: this stuff, I can point you at some topical words.
Nemokosch ... that $variables iterate as one single element? Is this the big problem @variables are meant to solve? This is already solved by zen-slicing, without the confusing semantics. 23:58
rir Else there is little reason to not use $ary with @#ary.
Oops, That should be your @$ary 23:59
Nemokosch @variables have no "assignment" (yes, they have "list assignment" but that's simply not a variable assignment if you are coming from any imperative language)
@variables don't work well with typing