00:16
yewscion joined
00:21
yewscion_ joined,
yewscion left
00:47
yewscion joined
00:48
yewscion_ left
01:01
Manifest0 left
|
|||
botato | raku's concurrency features look neat, so I want to implement some solutions to protohackers to learn it, but I'm stuck on the first problem: protohackers.com/problem/0 | 01:29 | |
a basic tcp echo server in raku is easy enough, but this has the complication that you don't echo their message right away, but read everything until they close, and then write everything back | 01:30 | ||
01:30
kylese left
|
|||
botato | but it seems IO::Socket::Async doesn't have the concept of half-closed connection? with tcp one side or the other should be able to close connection and it is half closed meaning they won't send anymore but can still receive, then when other side closes it's fully closed | 01:31 | |
to read everything first, and then write it back all at once I try: for $conn.Supply(:bin).list.eager -> $msg {$conn.write: $msg;} | 01:32 | ||
but when the other side half-closes the connection, so for sure there won't be anything more to receive, the Supply is still open, until I close my side of the connection | 01:33 | ||
01:34
kylese joined
|
|||
botato | I try non Async socket: gist.github.com/bo-tato/7930d618b4...142eccb3b8 and `echo "adsf" | nc localhost 1337 -v`, and it seems worse, that the recv call blocks forever even though the socket is fully closed | 01:41 | |
with the Socket::Async at least when socket is fully closed the Supply closes, just when the other side has half-closed the tcp connection the Supply is still open though it should be closed at that point I think | 01:42 | ||
can test as after EOF from the echo piped to nc, it half-closes the connection, then ctrl-C the nc to fully close it | 01:44 | ||
02:01
Aedil joined
02:07
MasterDuke joined
02:34
hulk joined
02:35
kylese left
02:42
yewscion left
03:11
yewscion joined
03:15
hulk left,
kylese joined
03:16
yewscion left
03:18
MasterDuke left
|
|||
timo | github.com/libuv/libuv/issues/3449 harumpf | 03:41 | |
botato | my bad if testing with nc you need -q0 so it sends half close as soon as it reads EOF | 04:37 | |
interesting issue, but here we don't have any RST flag | |||
echo server with IO::Socket::Async: gist.github.com/bo-tato/1f0a264c78...41217561d0 tcpdump log: gist.github.com/bo-tato/45262edebb...fa55634e24 as soon as it gets Fin flag from client, it sends back Fin and closes connection, never writing back the message | 04:40 | ||
echo server that passes the protohackers.com tests: `socat tcp-l:1337,fork,reuseaddr exec:cat` with tcpdump: gist.github.com/bo-tato/4b7b092cb5...c3bbbbe045 after it gets Fin from client it doesn't respond with Fin right away, but echoes the message back, then closes it's side with Fin | 04:42 | ||
is that possible with current raku socket library? | |||
05:00
librasteve_ left
06:02
zenmov left,
zenmov joined
06:03
zenmov left,
zenmov joined
06:05
zenmov left
06:06
zenmov joined
06:07
zenmov left
06:08
zenmov joined,
zenmov left,
zenmov joined
07:24
Sgeo left
07:27
[Coke] left
08:15
apac joined
|
|||
Geth | advent: pheix++ created pull request #117: Add post by pheix on KZG commitments and Ethereum v3 trxs |
08:30 | |
08:48
sena_kun joined
08:54
dakkar joined
08:55
guifa joined
|
|||
timo | very worst case, you can still NativeCall | 08:59 | |
09:01
Manifest0 joined
09:22
[Coke] joined
09:29
apac left
09:52
sena_kun left
|
|||
Geth | advent/main: 726baa649d | Kostas++ (committed using GitHub Web editor) | raku-advent-2024/authors.md Add post by pheix on KZG commitments and Ethereum v3 trxs (#117) |
10:18 | |
10:29
librasteve_ joined
|
|||
xinming | m: ((0..Inf) Z <a b c>).grep(*[1] eq "b").map(*[0]).raku.say | 10:45 | |
camelia | (1,).Seq | ||
timo | ^- can that use the :as named argument to grep? | 10:46 | |
xinming | Above example is a way to get index of an element, But wonders, Is there a function which is defined for this? returns indexes with a function without such onliners. | ||
timo | oh, of course | ||
there's .pairs, there's .kv, depending on how you would prefer to iterate over the thing | |||
and the :kv and :p or :pairs argument to grep | 10:47 | ||
lizmat | or even :k ! | ||
timo | m: say <a b c d e f>.grep("b", :k) | ||
camelia | (1) | ||
timo | m: say <a b c d e f a b c d a b c a b a b a>.grep("b", :k) | ||
camelia | (1 7 11 14 16) | ||
timo | m: say <a b c d e f a b c d a b c a b a b a>.grep("b", :kv) | ||
camelia | (1 b 7 b 11 b 14 b 16 b) | ||
xinming | timo: thanks for the :k thing. | 10:48 | |
This is why I love raku/perl | |||
quite expressive. :-) | |||
timo | it's also vaguely related to the schwartzian transform from perl that you can do without in raku in more places | 10:49 | |
also thank liz as well :) | |||
11:15
Manifest0 left
|
|||
xinming | m: my @x = [[1..3]] | 12:52 | |
camelia | ( no output ) | ||
xinming | m: my @x = [[1..3]]; @x.raku.say; | ||
camelia | [1, 2, 3] | ||
timo | m: my @x = [[1..3],]; dd :@x | ||
camelia | :x([[1, 2, 3],]) | ||
xinming | With this example, I know that ((1..3)) will be slipped makes sense. But why will [[]] be still slpped? | 12:53 | |
timo | it's not "slipped" per se, it's just iterated. this is the "single-argument rule" in action | ||
xinming | timo: Yea, I know that adding comma will work, But that makes me confuse | ||
timo | the [1..3] is the single argument to the outer circumfix:<[ ]> | ||
m: for [1,2,3] { "element: $_".say } | |||
camelia | element: 1 element: 2 element: 3 |
||
timo | m: for $[1,2,3] { "element: $_".say } | 12:54 | |
camelia | element: 1 2 3 | ||
timo | "unless it's an item" | ||
13:17
finanalyst joined
13:25
ashfield left,
greenfork left,
atweedie left,
patrickb left,
atweedie joined
13:26
greenfork joined,
ashfield joined,
patrickb joined
13:55
finanalyst left
14:05
guifa left
14:34
guifa joined
|
|||
xinming | m: my @x = <a b c>; my @idx = 1,2; my @t = @x; @x = (); @x[@idx] = @t[@idx]; @x.raku.say; | 14:49 | |
camelia | [Any, "b", "c"] | ||
xinming | In this example, Is there a way to remove the @t var and empty the @x in this case? | ||
I mean, preseving the array, But only keep portion of values | 14:50 | ||
timo | m: my @x = <a b c>; my @idx = 1,2; @x = @x[][@idx]; @x.raku.say; | 14:52 | |
camelia | ["b", "c"] | ||
timo | actually it also works without the empty [] | ||
or do you want the Any in there? | 14:53 | ||
xinming | timo: yea | 14:55 | |
I know the @x[@idx] thing, But it doesn't preserve the Array shape | 14:56 | ||
So my code do a backup, and cleanup original array, then assign items accordingly | |||
it's quite fine even we can't do that, I personally doesn't think this should be the language feature. Just try to make things more compact | 14:58 | ||
timo | i can think of things that are longer than what you wrote | 14:59 | |
m: my @x = <a b c>; my @idx = 1,2; @x .= map({ ($++ (elem) @idx) ?? $_ !! Any }); @x.raku.say | 15:02 | ||
camelia | [Any, "b", "c"] | ||
timo | it's only slightly longer than yours :\ | 15:03 | |
xinming | I thought about this idea too, just felt it's harder to understand. I think no built-in language feature for this. | 15:09 | |
dakkar | m: my @x=<a b c>; my @idx=1,2; @x[(@x.keys() (-) @idx).keys()]:delete;@x.raku.say | ||
camelia | [Any, "b", "c"] | ||
dakkar | "delete all indices not mentioned" | 15:10 | |
nahita3882 | you can reduce to @x[(^* ā @idx).keys]:delete if you wanted | 15:14 | |
that we need .keys is a little sad i think | |||
timo | are you a raku golfer? :D amazing | ||
i think you could shorten that to @x[keys ^* \ @idx:]:delete | 15:15 | ||
nahita3882 | i had the same idea as dakkar and was looking to shorten further :p | 15:20 | |
and it wasn't working without .keys on the Set produced, it was deleting "b", which is actually a bit mysterious unfortunately | 15:21 | ||
it takes the length of the Set when it is used directly as the indexer for some reason | 15:22 | ||
also your .map solution works even if the last item has to go; ours shorten the list length by 1 in that case | 15:23 | ||
also compiler gets confused on your indirect method invocation suggestion unfortunately | |||
timo | damn | ||
does it need [(@x....:)] to work? | 15:24 | ||
nahita3882 | i tried with parens in various places, it's still confused on the location of the infix ā | 15:25 | |
timo | ah, dang, so it would need parens around that and then there is no win from the : syntax | 15:26 | |
15:30
yewscion joined
15:34
dmvrtx_ joined,
dmvrtx left
|
|||
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/11/25/2024-...o-release/ | 16:23 | |
16:26
Manifest0 joined
16:35
yewscion left
|
|||
El_Che | hi lizmat, thank you | 16:49 | |
16:51
apac joined
17:13
yewscion joined
17:25
apac left
17:28
coleman left
17:30
coleman joined
17:37
yewscion left
17:38
dakkar left
17:53
yewscion joined
18:08
thowe left,
thowe joined
18:12
lizmat_ joined
18:15
lizmat left
18:17
BinGOs left,
bingos joined
18:21
lizmat_ left,
lizmat joined
|
|||
xinming | DarthGandalf: thanks for the idea, That version is acceptable to me | 18:48 | |
18:49
sena_kun joined
|
|||
xinming | @nahita3882 I don't like the @x[(keys ^* \ @idx:]:delete thing, As I don't understand how it worked. :-) | 18:49 | |
DarthGandalf | xinming: which one? | 19:02 | |
xinming | DarthGandalf: oops, sorry, wrong completion, I mean dakkar | 19:05 | |
timo | that's not the one that worked :D | 19:07 | |
that's my broken one | |||
antononcube | DarthDakkar? | ||
xinming | m: multi test-multi (@a) { @a.raku.say }; <a b c>.test-multi() | 19:09 | |
camelia | No such method 'test-multi' for invocant of type 'List' in block <unit> at <tmp> line 1 |
||
xinming | IIRC, before we can call test-multi as method for an object, Is my memory wrong? | 19:10 | |
timo | do it like .&test-multi() | 19:15 | |
xinming | timo: So, the syntax changed long ago, right? | 19:18 | |
thanks | |||
lizmat | it's been like thatfor 12 years at least :-) | ||
xinming | hmm, Ok, I'll need to refresh my memory for all these. | 19:20 | |
ab5tract | xinming: you also have this option: | 19:38 | |
m: my $a = <1 2 3> but role :: { method test-multi { say "testing!" } }; $a.test-multi | |||
camelia | testing! | ||
ab5tract | note that DWIMs with scalar container | ||
lizmat | .oO( sometimes I wish we could drop the "role :: { }" boilerplate |
19:39 | |
) | 19:40 | ||
.oO( also syntax like "is !built" for "is built(False)" ) |
19:44 | ||
timo | isn't built | 19:46 | |
lizmat | hmmmm | 19:52 | |
that would mean a new trait_mod | |||
timo | can't just make that a sub, right? has to go in the grammar as well? | 19:59 | |
or does it automatically do that just like operators do? | |||
m: multi sub trait-mod:<isn't>(Attribute $thing, :$built!) { say "haha" }; class A { has $.foo isn't built } | 20:00 | ||
camelia | ===SORRY!=== Error while compiling <tmp> Cannot add tokens of category 'trait-mod' at <tmp>:1 ------> multi sub trait-mod:<isn't><HERE>(Attribute $thing, :$built!) { say "haha |
||
20:00
abraxxa-home joined
20:42
apac joined
21:01
abraxxa-home left
21:37
Aedil left
21:40
librasteve_ left
|
|||
timo | asciinema.org/a/jKMWXHzKYk1tRdc7Xfc0wzcDD silly little "when you paste something in this line editor, you get to work on the stuff before it actually goes in" proof-of-concept / experiment | 21:56 | |
japhb, patrickb: check it out :) it's based on Terminal::LineEditor | |||
patrickb | oh wow! That's a slice'n'dice! | 21:58 | |
timo | it can almost send email, but not quite | 21:59 | |
don't ask what happens when the individual lines are too long to fit in one line ... :| | 22:03 | ||
i also accidentally half a lizmat's Commands module, but worse | 22:04 | ||
but really, a normal user would probably just want a keybind that launches $EDITOR | 22:05 | ||
guifa | random: do we have a clipboard module? | ||
ah we do | 22:06 | ||
timo | is it for the OSC 53 or whichever it is ansi escape sequence? or like xclip or so? | 22:07 | |
22:24
sena_kun left
|
|||
timo | i see now that it shells out to a commandline program that does the clipboard handling | 22:31 | |
22:36
sena_kun joined
22:38
apac left
|
|||
guifa | yeah works for a QAD manner, but I wonder what it gets when the clipboard has binary data | 22:40 | |
I've been trying to do systems stuff where the command line is the fall back but trying to do a native call as preferred | 22:41 | ||
I think User::Language was my first one with that model | |||
Geth | advent/finanalyst-patch-1: a7deb7c306 | (Richard Hainsworth)++ (committed using GitHub Web editor) | raku-advent-2024/authors.md Update authors.md Suggestion for Day 8 |
22:44 | |
advent: finanalyst++ created pull request #118: Update authors.md |
|||
22:49
Sgeo joined
23:05
Manifest0 left
23:07
Manifest0 joined
23:13
yewscion left
23:14
yewscion joined,
sena_kun left,
yewscion left
|
|||
Geth | advent/main: 193fe96f38 | (Richard Hainsworth)++ (committed using GitHub Web editor) | raku-advent-2024/authors.md Update authors.md (#118) Suggestion for Day 8 |
23:34 | |
23:35
Manifest0 left
23:36
Manifest0 joined
|