<< 23-09-2025 >>

00:22:23FromDiscord<systemblue_whale> Hey guys what IDE do you use when working with Nim?
00:26:10FromDiscord<systemblue_whale> hey can i use↵set, table, ref object, seq, tuple when working with C FFI/
00:26:15FromDiscord<systemblue_whale> (edit) "FFI/" => "FFI?"
00:27:31FromDiscord<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:25FromDiscord<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:12FromDiscord<systemblue_whale> you mean value type tuple, seq, table, set are okay to use?
00:29:42FromDiscord<systemblue_whale> but ref object is not freed by Nim until C is done with them?
00:29:44FromDiscord<systemblue_whale> right?
00:29:59FromDiscord<mitranim> Tuples are fixed-size value types (though you can put references into them). Anything resizable like `seq` or `Table` contains references
00:30:36FromDiscord<systemblue_whale> seq, Table is resizable so it's value type right?
00:32:29FromDiscord<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:40FromDiscord<mitranim> Something like that anyway
00:33:38FromDiscord<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:11FromDiscord<mitranim> Someone please correct me
00:39:33FromDiscord<Elegantbeef> You need to disable the destructors when passing to C if it takes ownership
00:39:36FromDiscord<Elegantbeef> You then need to return it back
00:40:31FromDiscord<Elegantbeef> Nim \<-\> C is best done with opaque pointers really
00:40:43FromDiscord<Elegantbeef> If you know what you're doing you can do it directly, but there is nothing automatic
00:42:30FromDiscord<mitranim> Nim's `seq` and `Table` are Nim-specific anyway, so it would be weird passing them to C
00:43:03FromDiscord<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:46FromDiscord<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:01FromDiscord<nervecenter> (edit) "get" => "you'll have"
01:13:11FromDiscord<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:55FromDiscord<Elegantbeef> you can also write the seq def on the C side and use it that way 😛
01:15:41FromDiscord<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:40FromDiscord<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:32FromDiscord<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:21FromDiscord<Laylie> precede it with `fgColor` or `bgColor`
14:11:11FromDiscord<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:40FromDiscord<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