00:22:23 | FromDiscord | <systemblue_whale> Hey guys what IDE do you use when working with Nim? |
00:26:10 | FromDiscord | <systemblue_whale> hey can i use↵set, table, ref object, seq, tuple when working with C FFI/ |
00:26:15 | FromDiscord | <systemblue_whale> (edit) "FFI/" => "FFI?" |
00:27:31 | FromDiscord | <systemblue_whale> I'm confused that is it okay to use non-basic type with C FFI↵array, type, object, ptr object is okay to use when working with C FFI↵but how about set, table, ref object, seq, tuple |
00:28:25 | FromDiscord | <mitranim> Value types are safe. When using reference types, you must ensure they're not freed by Nim until C is done with them (and that C doesn't retain them) |
00:29:12 | FromDiscord | <systemblue_whale> you mean value type tuple, seq, table, set are okay to use? |
00:29:42 | FromDiscord | <systemblue_whale> but ref object is not freed by Nim until C is done with them? |
00:29:44 | FromDiscord | <systemblue_whale> right? |
00:29:59 | FromDiscord | <mitranim> Tuples are fixed-size value types (though you can put references into them). Anything resizable like `seq` or `Table` contains references |
00:30:36 | FromDiscord | <systemblue_whale> seq, Table is resizable so it's value type right? |
00:32:29 | FromDiscord | <mitranim> When you have a handle on a `seq` or `Table`, it's a value which is either a reference or a struct with some references (it's opaque and the implementation may change). It references heap memory managed by Nim. The memory is freed at some point after the handle's lifetime ends |
00:32:40 | FromDiscord | <mitranim> Something like that anyway |
00:33:38 | FromDiscord | <mitranim> I haven't used Nim for C interop but I'm about 90% sure the docs say somewhere that tracking the lifetimes of stuff you pass to C is your responsibility |
00:34:11 | FromDiscord | <mitranim> Someone please correct me |
00:39:33 | FromDiscord | <Elegantbeef> You need to disable the destructors when passing to C if it takes ownership |
00:39:36 | FromDiscord | <Elegantbeef> You then need to return it back |
00:40:31 | FromDiscord | <Elegantbeef> Nim \<-\> C is best done with opaque pointers really |
00:40:43 | FromDiscord | <Elegantbeef> If you know what you're doing you can do it directly, but there is nothing automatic |
00:42:30 | FromDiscord | <mitranim> Nim's `seq` and `Table` are Nim-specific anyway, so it would be weird passing them to C |
00:43:03 | FromDiscord | <mitranim> Normally it's the other way around: importing a C library and matching its structures in Nim |
01:00:44 | * | SchweinDeBurg quit (Quit: WeeChat 4.8.0-dev) |
01:11:42 | * | om3ga quit (Ping timeout: 252 seconds) |
01:12:46 | FromDiscord | <nervecenter> In reply to @mitranim "I haven't used Nim": Basically true, to pass to C you have to use the `pointer` type and it's entirely up to you to `dealloc`. A `seq` is basically a fat pointer to a doubling arraylist, but you can absolutely get the address of the first element and get the address of the allocated memory. |
01:13:01 | FromDiscord | <nervecenter> (edit) "get" => "you'll have" |
01:13:11 | FromDiscord | <nervecenter> (edit) "In reply to @mitranim "I haven't used Nim": Basically true, to pass to C you have to use the `pointer` type and it's entirely up to you to `dealloc`. A `seq` is basically a fat pointer to a doubling arraylist, but you can absolutely get the address of the first element and you'll have the address of the allocated ... memory." added "array" |
01:13:55 | FromDiscord | <Elegantbeef> you can also write the seq def on the C side and use it that way 😛 |
01:15:41 | FromDiscord | <mitranim> With the caveat that the definition of `seq` is not cleanly exposed in Nim 2 and seems different in Nimony, where it _doesn't_ start with the array pointer (which is IMO weird) |
01:16:15 | * | thunder joined #nim |
01:16:40 | FromDiscord | <mitranim> (edit) "weird)" => "weird because of exactly this use case)" |
03:14:29 | * | redj joined #nim |
03:40:17 | * | SchweinDeBurg joined #nim |
04:24:28 | * | thunder quit (Remote host closed the connection) |
04:24:57 | * | thunder joined #nim |
06:37:23 | * | om3ga joined #nim |
08:41:57 | * | beholders_eye joined #nim |
08:49:34 | * | acidsys quit (Ping timeout: 255 seconds) |
09:02:47 | * | acidsys joined #nim |
12:15:10 | * | beholders_eye quit (Ping timeout: 258 seconds) |
13:17:32 | FromDiscord | <kiloneie> Is there a way to have `rgb` be selected to affect foreground or background, instead of it being background everytime ? Without having to break down the echo into multiple proc calls ? https://media.discordapp.net/attachments/371759389889003532/1420036358742868049/Screenshot_2025-09-23_15-13-04.png?ex=68d3ef6a&is=68d29dea&hm=bb9155727fc6e3f37717561fa1088a05b6a65eff3814995565182acb6c4fe44e& |
13:43:21 | FromDiscord | <Laylie> precede it with `fgColor` or `bgColor` |
14:11:11 | FromDiscord | <kiloneie> In reply to @Laylie "precede it with `fgColor`": This does not have the desired effect. What you suggested is more of a "mixing of the colors". |
15:24:40 | FromDiscord | <Laylie> ok, works for me |
15:27:40 | * | przmk quit (Remote host closed the connection) |
15:28:07 | * | przmk joined #nim |
16:03:26 | * | cm_ joined #nim |
16:03:50 | * | cm quit (Read error: Connection reset by peer) |
16:03:53 | * | cm_ is now known as cm |
16:11:37 | * | beholders_eye joined #nim |
16:42:08 | * | SchweinDeBurg quit (Quit: WeeChat 4.8.0-dev) |
18:38:48 | * | SchweinDeBurg joined #nim |
18:46:10 | * | beholders_eye quit (Ping timeout: 258 seconds) |
19:17:31 | * | beholders_eye joined #nim |
20:51:02 | * | beholders_eye quit (Ping timeout: 256 seconds) |
21:37:00 | * | rockcavera joined #nim |