|
02:22
sibl joined
04:01
stanrifkin left
|
|||
| disbot11 | <simon_sibl> with NativeCall rs // example code const std = @import("std"); const Action = enum(u8) { Allow, Deny, Reject }; const Proto = enum(u8) { tcp, udp }; const Rule = extern struct { action: Action, proto: Proto, port: u32, }; export fn apply_rule(rule: Rule) bool { std.debug.print("[*] Applying rule: action: {s}, proto: {s}, port: {d}\n", .{ @tagName(rule.action), @tagName(rule.proto), | 05:52 | |
| rule.port, }); return true; } How would I use that enum in Raku, just uint8 or there is a way I can make enum Proto <tcp udp> works in a way to have some safety with the value ? | |||
|
09:09
dakkar joined
09:31
sibl left
|
|||
| disbot11 | <librasteve> @simon_sibl - great question ... just to mention that while backticks are fine for those of us who are on Discord, folks who live over the bridge in IRC land (who are generally wiser and more attractive) get this somewhat garbled ... suggest sharing a gist for anything over a couple of lines ... keep em coming | 11:01 | |
| <simon_sibl> thanks for the recommendation, I will keep using glot.io for sharing code next 🙏 | 11:23 | ||
| <simon_sibl> so I have this zig code which is just a silly function to emulate a shared library that interact with the system: glot.io/snippets/henow4avyn | |||
| <simon_sibl> and I have this code in Raku to interact with it: glot.io/snippets/henoxa5vmm | 11:24 | ||
| <simon_sibl> I just wonder, if there is a better way to deal with the enum than what I am doing, and since enum are integers under the hood, will it be possible to use them in the future in the struct directly ? | |||
| lizmat | m: enum FOO (a => "foo", b => "bar"); dd +a # enums are *not* always just integers under the hood | 11:53 | |
| camelia | Failure.new(exception => X::Str::Numeric.new(source => "foo", pos => 0, reason => "base-10 number must begin with valid digits or '.'")) | ||
| disbot11 | <comulonymphus> I don't understand concurrency. Could anyone give me a simple example and an explanation, please? | 12:20 | |
| lizmat | m: await (start { for <a b c d> { sleep .1; .say } }, start { for ^4 { sleep .2; .say } }) | 12:30 | |
| camelia | a b 0 c d 1 2 3 |
||
| lizmat | note that the two lists of values are intermixed, as they ran concurrently with different delays | 12:31 | |
| disbot11 | <simon_sibl> lizmat oooh ok, I guess I was stuck in my C/Zig mindset of enum, then I understand why it cant work with Native call | 12:56 | |
| lizmat | well, by default they are ints | 12:58 | |
| m: enum foo <a b c d>; say +a; say +d | |||
| camelia | 0 3 |
||
| lizmat | just make sure to use the numeric value of them | 12:59 | |
| dev.to/lizmat/raku-resolutions-17g7 | 13:18 | ||
| disbot11 | <simon_sibl> > when it became clear that Larry Wall would not be around much more to decide on matters related to what is now the Raku... | 14:09 | |
| <simon_sibl> what happened with Larry ? 🥹 | 14:10 | ||
| lizmat | good question: I assume health and burnout played a role | 14:15 | |
| I mean: he's still alive and every now and then comments on an issue (like maybe once or 2x a year) | 14:16 | ||
| I would argue that the last "big" thing he did, was endorsing the name change in 219 | 14:17 | ||
| disbot11 | <shimmerfairy> Absent any other information, I'd assume it's just that he's old and effectively retired. | 14:21 | |
| lizmat | *2019 | 14:26 | |
| yes, but I would say: "decided to retire" rather than "retired" :-) | |||
|
18:08
dakkar left
20:38
habere-et-disper joined
21:12
habere-et-disper left
21:33
habere-et-disper joined
21:45
habere-et-disper left
22:31
habere-et-disper joined
22:59
habere-et-disper left
|
|||