<< 17-09-2023 >>

00:02:39FromDiscord<sOkam! 🫐> looks like im in for a rough debugger C-side stepping session for the next few days ⚰️
00:05:35FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GAl
00:06:32FromDiscord<Elegantbeef> `r.swapChain.cfg.addr.isNil` is funny
00:06:36FromDiscord<Elegantbeef> It'll never be nil
00:06:49FromDiscord<sOkam! 🫐> yeah, but how do i check for nil in those things?
00:06:59FromDiscord<Elegantbeef> I don't know what `cfg` is
00:07:01FromDiscord<Elegantbeef> Is it a struct
00:07:03FromDiscord<Elegantbeef> A ref
00:07:05FromDiscord<sOkam! 🫐> i just don't know whats crashing
00:07:10FromDiscord<sOkam! 🫐> its an object
00:07:28FromDiscord<Elegantbeef> Objects cannot be nil so that check is odd
00:07:36FromDiscord<sOkam! 🫐> yeah its random stuff
00:07:45FromDiscord<sOkam! 🫐> idk whats crashing, just threw crap to the wall
00:08:07FromDiscord<Elegantbeef> `r.swapChain.cfg.addr` is where I'd say it's likely to be seg faulting
00:08:34FromDiscord<sOkam! 🫐> what could cause that object to be optimized away?
00:08:42FromDiscord<Elegantbeef> what does that create proc expect
00:08:43FromDiscord<Elegantbeef> like the implementation
00:08:54FromDiscord<sOkam! 🫐> an addr of the swapchain descriptor
00:08:57FromDiscord<Elegantbeef> The implication is that it is getting optimised away
00:09:30FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GAn
00:09:49FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GAo
00:11:37FromDiscord<Elegantbeef> What do the docs say for `wgpuDeviceCreateSwapChain`
00:14:55FromDiscord<sOkam! 🫐> err... i cannot find it 🧩
00:15:40FromDiscord<Elegantbeef> Well I've done all that can be done
00:16:26FromDiscord<sOkam! 🫐> idk rust, but this is what it does↵https://github.com/gfx-rs/wgpu-native/blob/2773864b0b34bb6a5656ca815cad22c45a99154f/src/lib.rs#L2392-L2420
00:16:48FromDiscord<Elegantbeef> Uhh
00:17:00FromDiscord<Elegantbeef> `Option<T>` is not `ptr SwapChainDescriptor`
00:17:51FromDiscord<Elegantbeef> Your third argument is not the right type, so that this worked at all is amazing
00:19:24FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GAr
00:19:52FromDiscord<Elegantbeef> I mean we found the issue
00:20:12FromDiscord<Elegantbeef> You're passing a `ptr T` to something expecting `RustOption[ptr T]`
00:20:50FromDiscord<sOkam! 🫐> In reply to @Elegantbeef "You're passing a `ptr": https://github.com/webgpu-native/webgpu-headers/blob/8e9025e0fa4b33d5e7cc682b7604b021b29f36c6/webgpu.h#L1648
00:21:04FromDiscord<sOkam! 🫐> not really? or am I missing something huge?
00:21:18FromDiscord<Elegantbeef> Look at `descriptor`
00:21:19FromDiscord<sOkam! 🫐> like... wouldn't that mean the app crashes -allways?
00:21:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4GAt
00:21:22FromDiscord<Elegantbeef> It's an `Option[T]`
00:21:35FromDiscord<sOkam! 🫐> yeah... but its working normally without --debugger:native
00:21:46FromDiscord<sOkam! 🫐> the app resizes without issues
00:22:01FromDiscord<Elegantbeef> I mean nice, but what is Rust's implementation of `Option<&T>`
00:22:03FromDiscord<sOkam! 🫐> and I mapped the C headers, which say that it is a ptr Struct
00:22:14FromDiscord<ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=
00:22:27FromDiscord<Elegantbeef> If Rust's option does what Nim's do then it's probably fine to treat it as a pointer
00:22:30FromDiscord<ravinder387> is it enough command to create production code
00:22:36FromDiscord<Elegantbeef> If Rust's options do not do what Nim's do it's not ok
00:22:44FromDiscord<Elegantbeef> `-d:release -d:lto` are more like it
00:23:06FromDiscord<Elegantbeef> Nim's options turns pointer types into a wrapped sentinel value where `nil` is invalid
00:23:26FromDiscord<Elegantbeef> I do not know why the debugger changes the behaviour, like I said all I know indicates it shouldnt
00:23:43FromDiscord<Elegantbeef> But i'm pointing you to where a problem may exist
00:25:08FromDiscord<sOkam! 🫐> @beef https://stackoverflow.com/a/39007323
00:25:22FromDiscord<sOkam! 🫐> apparently its just a nullable pointer in terms of the FFI
00:25:39FromDiscord<Elegantbeef> Right then the ABI means a pointer is fine
00:26:00FromDiscord<sOkam! 🫐> yeah, otherwise it wouldn't work
00:26:19FromDiscord<sOkam! 🫐> also, running with `RUST_BACKTRACE=1` doesn't trigger anything, which means that rust code is not even reached
00:26:27FromDiscord<sOkam! 🫐> its crashing on the nim+c side
00:27:36FromDiscord<Elegantbeef> Compile with `-d:useMalloc --debugger: native` and run it throw valgrind
00:28:21FromDiscord<Elegantbeef> through\
00:30:15FromDiscord<sOkam! 🫐> what do I track, if --debugger:native does not fail?
02:31:20FromDiscord<millymox> Trying to make a command line tool, does nim have a command line parser?
02:32:59FromDiscord<Elegantbeef> There are a bunch there is parseopt in the stdlib and then many on nimble
02:34:14NimEventerNew Nimble package! unicody - An alternative / companion to std/unicode, see https://github.com/guzba/unicody
02:39:19*xmachina joined #nim
04:35:25*rockcavera quit (Remote host closed the connection)
05:07:47FromDiscord<sOkam! 🫐> Can nimc compile code directly from a string in cli, instead of from a file?
05:12:37FromDiscord<nasuray> In reply to @millymox "Trying to make a": cligen is my preference for cli
05:24:09FromDiscord<Phil> In reply to @ShalokShalom (ShalokShalom) "Why would you consider": Because it is implementing an entire new logic space that you need to learn.↵It is a gargantuan "you just gotta know this" field. And you need to translate the DSL and that may have not that easy to see logic errors attached.↵It is a last resort when the complexity of your problem domain is so intimidating you need to tame it somehow that isn't code because you lose o
05:30:19FromDiscord<nnsee> In reply to @heysokam "Can nimc compile code": maybe something like `nim c <(echo 'echo "hello world"')`
05:32:56FromDiscord<sOkam! 🫐> In reply to @nnsee "maybe something like `nim": i honestly doubt that works across platforms
05:33:12FromDiscord<sOkam! 🫐> considering `cd folder; command` breaks on windows 🤷‍♂️
05:34:31FromDiscord<nnsee> oh definitely not lol
05:35:03FromDiscord<nnsee> i mean there is also the `eval` flag
05:35:15FromDiscord<nnsee> which can evaluate straight from the command line
05:35:41FromDiscord<sOkam! 🫐> im trying to shortcut the fact that `gorge, gorgeEx` are the only ways to run a command in cli from the VM (like inside the nimc processing of a file)... by actually compiling a file that just does `execShellCmd( args.join(" ") )`
05:36:09FromDiscord<sOkam! 🫐> because the VM itself doesnt not have shell executing
05:36:36FromDiscord<sOkam! 🫐> (edit) "because the VM itself doesnt not have shell executing ... " added "without eating the output into a buffer and not showing it in stdout"
05:37:57FromDiscord<sOkam! 🫐> so was thinking of something like `nim c --outDir:someDir "mycode; otherline; other"` or similar, without needing a second intermediate step of writing a code file somewhere
05:38:31FromDiscord<nnsee> what are you trying to do
05:38:51FromDiscord<nnsee> in the grander scheme of things
05:38:57FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GBl
05:39:04FromDiscord<sOkam! 🫐> there is no execshellcmd in the VM
05:39:39FromDiscord<sOkam! 🫐> only gorge/gorgeEx which eat the output for themselves, and the console just freezes while cargo is running to build the static lib which the compiled project depends on
05:40:02FromDiscord<sOkam! 🫐> then all of a sudden the entire output of cargo is printed all at once to console, when its done
05:42:17FromDiscord<odexine> https://nim-lang.org/docs/nimscript.html#exec%2Cstring ?
05:43:27FromDiscord<nnsee> yeah i feel like there are like a dozen variations of this for nimble
05:49:31FromDiscord<nnsee> or just a few
06:08:45FromDiscord<sOkam! 🫐> In reply to @odexine "https://nim-lang.org/docs/nimscript.html#exec%2Cstr": exec does not work on the vm
06:09:15FromDiscord<odexine> ????
06:09:21FromDiscord<odexine> it says right there "nimscript"
06:09:38FromDiscord<sOkam! 🫐> this is not `when defined(nimscript)` its `when nimvm`
06:09:53FromDiscord<odexine> what context are you even in right now
06:10:19FromDiscord<sOkam! 🫐> this https://github.com/heysokam/wgpu/blob/4f23d2f7fe2fb93b8b432e14a27cfdc31e973279/src/wgpu/compile.nim#L24
06:10:33FromDiscord<sOkam! 🫐> which runs this:↵https://github.com/heysokam/wgpu/blob/4f23d2f7fe2fb93b8b432e14a27cfdc31e973279/src/wgpu/compile.nim#L54-L55
06:15:00FromDiscord<odexine> wouldnt this be better in a nim config file
06:15:29FromDiscord<odexine> let me think
06:19:13FromDiscord<sOkam! 🫐> I tried my best to make it work in nimble
06:19:45FromDiscord<sOkam! 🫐> if you have a way to do it let me know, but I failed with everything I tried and resorted to just use a static block instead
06:20:17FromDiscord<sOkam! 🫐> because otherwise the only other solution I saw was to send the complexity of the buildsystem to the user, which is a really crappy solution
06:20:49FromDiscord<odexine> you can always do what piconim did and have a builder binary
06:21:20FromDiscord<sOkam! 🫐> or just have a shell-runner binary that can exec from nimvm
06:21:48FromDiscord<sOkam! 🫐> ideally there should just be an exec or execshellcmd version inside the vm
06:21:50FromDiscord<sOkam! 🫐> (edit) "vm" => "nimvm"
06:22:09FromDiscord<sOkam! 🫐> since the functionality is already there for gorge
06:38:49*ntat joined #nim
07:51:10FromDiscord<pk.kyle> any quick and handy gui framework that lets me generate latex
07:51:19FromDiscord<pk.kyle> i dont want my math equations to look shit \:(
07:51:31*FromDiscord quit (Remote host closed the connection)
07:51:44*FromDiscord joined #nim
07:57:03*Mister_Magister quit (Read error: Connection reset by peer)
07:58:51*Mister_Magister joined #nim
07:59:45FromDiscord<Phil> In reply to @pk.kyle "any quick and handy": As in, that renders latex visually or as in a way to generate latex notation?
07:59:53FromDiscord<pk.kyle> former
08:01:08FromDiscord<Phil> https://xigoi.srht.site/matext/ might fit the bill.↵Haven't used it myself but I don't use Latex generally
08:01:53FromDiscord<pk.kyle> oh thx
08:02:40FromDiscord<Phil> Other than that you can always `nimble search latex` and skim through the descriptions for something that sounds right
08:09:46FromDiscord<pk.kyle> ah, i forgot that command exists
08:09:55FromDiscord<pk.kyle> thx
08:13:49FromDiscord<Phil> Happy to help 😉
08:25:26*junaid_ joined #nim
08:46:36*ntat quit (Quit: leaving)
08:48:36FromDiscord<Chronos [She/Her]> In reply to @ShalokShalom (ShalokShalom) "Why would it run": Because for stock JDKs it has to run in interpreted mode
08:48:41FromDiscord<Chronos [She/Her]> And that would be piss poor
08:53:19FromDiscord<Chronos [She/Her]> Also still means I have to recompile for every possible platform
09:10:42FromDiscord<vindaar> In reply to @pk.kyle "any quick and handy": Check out https://github.com/Vindaar/latexdsl↵also comes with a convenient compile command 👌 (depends on a local tex installation obviously, I'm not a madman)
09:12:37FromDiscord<pk.kyle> lol, thx!
09:18:54FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GCe
09:19:45FromDiscord<vindaar> You can pass a `tmpl` argument to `compile` to replace the default template, defined here: https://github.com/Vindaar/LatexDSL/blob/master/src/latexdsl/latex_compiler.nim#L10-L20
09:25:30*FromDiscord quit (Remote host closed the connection)
09:25:43*FromDiscord joined #nim
09:49:01arkanoidhow can I get a longer list of trending packages in nimble.directory?
10:28:09FromDiscord<Phil> I don't think that query is paginated
10:33:27*PMunch joined #nim
10:36:03*blackbeard420 quit (Server closed connection)
10:36:15*blackbeard420 joined #nim
10:36:39FromDiscord<pk.kyle> In reply to @vindaar "By compile command, what": ok!
10:36:50FromDiscord<pk.kyle> (edit) "ok!" => "ok thx!"
10:51:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GCu
10:51:51FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4GCu" => "https://play.nim-lang.org/#ix=4GCv"
10:52:07FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4GCv" => "https://play.nim-lang.org/#ix=4GCw"
10:55:39FromDiscord<Phil> Actually I might be able to save myself the custom cstring type by just straight converting to string 🤔
10:55:39FromDiscord<vindaar> I assume the `g_file_get_path` that returns `cstring` is a wrapped function from some library? In that case normally I would go with your approach, using the opportunity to have a nicer Nim like interface.↵However, given that distinct types are a pure Nim construct, I suppose you can just define the `importc` function to return your `distinct` type. That _should_ work I imagine, but I've never tried it
10:56:10FromDiscord<Phil> In reply to @vindaar "I assume the `g_file_get_path`": It is, this is for owlkettle, a gtk4 wrapper
10:58:03FromDiscord<vindaar> In reply to @vindaar "I assume the `g_file_get_path`": thinking about what I just said: I obviously have tried exactly that, haha. I define plenty of imported types by just doing a `distinct c<foo>`, which is pretty much identical
10:58:55FromDiscord<Phil> Check, so by using distinct type we can pretty easily distinguish between c-types whose memory we don't manage and c-types whose memory we do manage?
11:01:09FromDiscord<Phil> Now the more fundamental question.... err how do I free the memory of a cstring 😅
11:01:39FromDiscord<Phil> So far I only ever had to reduce ref-counts by calling a proc from gtk since they were the ones freeing the memory
11:01:55FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GCB
11:02:24FromDiscord<vindaar> If gtk4 hands you that cstring, doesn't its documentation tell you what you're supposed to do with it? Or does it just say "you're responsible to free it"?
11:02:57FromDiscord<Phil> In reply to @vindaar "If gtk4 hands you": The latter. I quote:https://docs.gtk.org/gio/method.File.get_path.html↵> The caller of the method takes ownership of the data, and is responsible for freeing it.
11:04:37FromDiscord<Phil> This is a nim-syntax question though right? I'm mostly asking because I see procs with dealloc prefixes, others with with "free" prefixes (though there's also a literal "free" proc without any docs) and I'm not sure what the path here is
11:05:00FromDiscord<odexine> In reply to @isofruit "The latter. I quote:https://docs.gtk.org/gio/method": doesnt mean they dont provide how to free it, just means that you have to put the code to free it yourself
11:05:20FromDiscord<odexine> In reply to @odexine "doesnt mean they dont": how to free it via a proc like g_whatever_free(ptr)
11:07:17FromDiscord<Phil> In reply to @odexine "doesnt mean they dont": I feel like if they did they'd have linked it
11:07:22FromDiscord<vindaar> either what Rika says or:↵the question is where does the `char ` come from then. If they `malloc` internally, then I guess you need to free manually yes. As I don't think you should use `dealloc` from Nim's stdlib (that should refer to Nim's allocator, which may not be `malloc` unless you use `-d:useMalloc`, you should best wrap `free` from `stdlib.h`
11:08:16FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GCE
11:10:11FromDiscord<vindaar> (note that both of these will format your code and not return it verbatim like you print the `code` string there)
11:10:34FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GCH
11:10:57FromDiscord<Phil> sent a long message, see http://ix.io/4GCI
11:11:19FromDiscord<Phil> In reply to @vindaar "either what Rika says": Does this imply that a memory allocated via allocator A must also be deallocated by allocator A and you can't do that via allocator B?
11:11:37FromDiscord<Phil> (edit) "B?" => "B?↵So allocators are not interoperable in that sense?"
11:11:48FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GCJ
11:11:52FromDiscord<Phil> (edit) "In reply to @vindaar "either what Rika says": Does this imply that a ... memory" added "piece of"
11:13:30FromDiscord<vindaar> In reply to @isofruit "Does this imply that": Honestly, I never thought about that before, but it seems intuitively that it is not a good idea. The allocator knows which pointers it allocated, no? So if you use allocator B for buffer from A it seems like they would be out of sync and B wouldn't know about what is there to free?
11:13:53FromDiscord<Phil> Allocators "remember" the memory they allocated?
11:13:55FromDiscord<Phil> TIL
11:14:11FromDiscord<vindaar> How else would they know how much there is to free given a void pointer?
11:14:14FromDiscord<.aingel.> Say if I have a `var a: seq[ptr someObj]` and I want to pass this to a `proc foo(ctx: pointer)` , do I pass `foo (ref a)` or `foo (ptr a)` and what's the diff?
11:14:31FromDiscord<Phil> I thought it was a stateless operation in a sense, you ask for memory, they hand you some, notify everyone involved and then forget about it. Then you hand them the memory back, they analyze at runtime what they need to deallocate and then do so
11:14:42FromDiscord<vindaar> (I'm just assuming here, I'm not an allocator expert 🤣 )
11:15:22FromDiscord<Phil> Wait, that has performance implications... I guess this kind of approach was used for better performance rather than having some kind of bit-pattern that denotes the edges of an allocation region
11:15:27FromDiscord<vindaar> maybe they pass it up one layer, that's possible. so the kernel keeps the info. But for a custom allocator?
11:15:58FromDiscord<vindaar> It's something to read up on I guess 😁
11:23:16FromDiscord<ieltan> In reply to @.aingel. "Say if I have": I assume you're doing c interop but first of all are you sure you need `pointer` instead of `ptr T`?
11:23:35FromDiscord<.aingel.> yeah I need it as a void
11:23:53FromDiscord<.aingel.> Well, can I pass a non void pointer if the function wants it?
11:24:36FromDiscord<.aingel.> I keep getting now cannot cast to pointer
11:25:08FromDiscord<ieltan> I didn't mess around much with raw pointer I think you'll need to wait for someone more knowledgeable 😦
11:25:35FromDiscord<.aingel.> Okie cool!
11:25:49FromDiscord<odexine> I don’t exactly understand your question
11:25:59FromDiscord<odexine> You want to turn a into a void pointer?
11:26:20FromDiscord<odexine> You can just cast
11:26:23FromDiscord<ieltan> You could do `pointer(a)` I think but I really don't guarantee any safeness
11:26:28FromDiscord<ieltan> Or cast
11:26:51FromDiscord<ieltan> I think you can type convert `ptr T` to `pointer` right?
11:26:58FromDiscord<odexine> Not sure
11:27:00FromDiscord<odexine> Never did
11:28:28FromDiscord<vindaar> @.aingel. the most important question first of all is what does the function actually want in terms of data. The entire buffer of all `ptr someObj`?
11:28:40FromDiscord<vindaar> In that case just do `cast[pointer](a[0].addr)`
11:29:05FromDiscord<.aingel.> In reply to @odexine "You can just cast": Not sure I follow that
11:29:07FromDiscord<.aingel.> What's a there
11:29:12FromDiscord<.aingel.> (edit) "a" => "`a`"
11:29:38FromDiscord<odexine> My bad. I misread
11:29:42FromDiscord<odexine> An element of a
11:29:44FromDiscord<.aingel.> No I want a pointer to a seq of someojbs
11:29:46FromDiscord<odexine> Is what I mean
11:29:51FromDiscord<odexine> Ah
11:30:10FromDiscord<.aingel.> (edit) "someojbs" => "someobjs"
11:30:15FromDiscord<odexine> You can’t make references without copies
11:30:24FromDiscord<odexine> So if you don’t mind then go with the pointer
11:30:34FromDiscord<.aingel.> In reply to @odexine "You can’t make references": What do you mean?
11:30:37FromDiscord<odexine> By taking the address of a then casting
11:30:48FromDiscord<.aingel.> What's the dif between ptr and ref?
11:31:02FromDiscord<odexine> You can make pointers to non-heap data
11:31:05FromDiscord<ieltan> Managed vs unmanaged pointer
11:31:14FromDiscord<ieltan> And above
11:31:16FromDiscord<odexine> References are always heap and if the data isn’t already in the heap it will be copied
11:31:17FromDiscord<.aingel.> In reply to @ieltan "Managed vs unmanaged pointer": Oh okay, that's what I thought
11:31:34FromDiscord<.aingel.> In reply to @odexine "References are always heap": Ptr can be to the stack?
11:31:38FromDiscord<ieltan> Yeah
11:31:39FromDiscord<odexine> Yes
11:31:50FromDiscord<.aingel.> Okie so if i don't care I can just use ptr
11:31:55FromDiscord<odexine> Sequences are in heap, but the semantics are as if they are not so it will still copy
11:32:02FromDiscord<.aingel.> Oh
11:32:13FromDiscord<odexine> In reply to @odexine "Sequences are in heap,": For references
11:32:19FromDiscord<ieltan> But that's why it's very unsafe since if the value goes out of scope the stack will pop it and the pointer becomes dangling
11:32:20FromDiscord<.aingel.> In reply to @odexine "Sequences are in heap,": It will make another copy?
11:32:26FromDiscord<odexine> If you use references yes
11:32:27FromDiscord<ieltan> Hope I got this right lol
11:32:38FromDiscord<.aingel.> In reply to @ieltan "But that's why it's": Hmmm
11:32:40FromDiscord<odexine> You did yes
11:32:55FromDiscord<.aingel.> In reply to @ieltan "But that's why it's": It won't deallocate the memory?
11:33:19FromDiscord<odexine> It will, but it might while you’re still using the data
11:33:21FromDiscord<ieltan> It will
11:33:28FromDiscord<.aingel.> Oh okay I think I get it
11:33:47FromDiscord<.aingel.> But okay, the main issue is that when I try to cast as pointer, I get `expected type`
11:33:55FromDiscord<odexine> So make sure the pointer is deleted or removed before you lose scope of the a variable
11:34:12FromDiscord<odexine> cast[pointer](addr a)
11:34:17FromDiscord<odexine> Is that what you did?
11:34:32FromDiscord<.aingel.> No I did ptr a
11:34:45FromDiscord<.aingel.> `cast[pointer](ptr a)`
11:34:49FromDiscord<odexine> That’s wrong
11:34:57FromDiscord<.aingel.> Why is it addr now
11:35:03FromDiscord<odexine> ptr is the type, addr is to get the pointer to a
11:35:16FromDiscord<.aingel.> Whats ref then
11:35:18FromDiscord<.aingel.> It's also a type?
11:35:20FromDiscord<odexine> Also a type
11:35:29FromDiscord<odexine> You get a ref in a different way
11:35:39FromDiscord<odexine> pointer is also a type
11:35:51FromDiscord<.aingel.> So the type determines whether it's managed or unmanaged
11:35:56FromDiscord<odexine> Its like the difference between and & in C
11:36:16FromDiscord<odexine> is a pointer (when on a type)
11:36:31FromDiscord<odexine> & gets you the pointer to the variable
11:36:36FromDiscord<odexine> (edit) "" => "\"
11:36:59FromDiscord<odexine> Same in Nim, ptr and addr
11:37:08FromDiscord<odexine> In reply to @.aingel. "So the type determines": Kinda
11:37:20FromDiscord<odexine> addr is strictly for pointers, it doesnt make refs
11:37:35FromDiscord<Phil> sent a long message, see http://ix.io/4GCO
11:37:50FromDiscord<Phil> (edit) "http://ix.io/4GCO" => "http://ix.io/4GCP"
11:37:57FromDiscord<odexine> In reply to @isofruit "I would like to": no
11:38:08FromDiscord<Phil> F.M.L.
11:38:11FromDiscord<odexine> If they do not specify then there is a documentation problem
11:38:42FromDiscord<_nenc> sent a code paste, see https://play.nim-lang.org/#ix=4GCQ
11:39:08FromDiscord<ieltan> The joy of C right
11:39:48FromDiscord<odexine> In reply to @ieltan "The joy of C": IKR
11:40:22FromDiscord<Phil> I don't know why people do this to themselves, I can only assume C-programmers are a cult of masochists
11:40:41FromDiscord<odexine> More, insane people
11:41:00FromDiscord<.aingel.> ` var nodes = (cast[ptr seq[string]](ctx))[]`
11:41:15FromDiscord<Phil> Without knowing that this is for, this looks cursed as hell
11:41:16FromDiscord<.aingel.> Is this the right way of deref my void pointer?
11:41:19FromDiscord<odexine> In reply to @.aingel. "` var nodes": That looks sketchy as fuck
11:41:28FromDiscord<ieltan> Oh my. God
11:41:32FromDiscord<odexine> Why is it suddenly a string
11:41:37FromDiscord<.aingel.> How do I deref my pointer
11:41:44FromDiscord<.aingel.> I want a seq of strings just to make it simple
11:41:55FromDiscord<.aingel.> So I want to pass a seq[string] to a c void arg
11:41:57FromDiscord<ieltan> Don't cast it to `string`, make it a `cstring` at least
11:41:58FromDiscord<.aingel.> and then use it there
11:42:09FromDiscord<Phil> Aingel immediately causing people to dogpile 😄
11:42:11FromDiscord<.aingel.> Why would I have to use cstring
11:42:13FromDiscord<ieltan> But then again that's not the biggest issue, what are you trying to accomplish
11:42:22FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GCW
11:42:33FromDiscord<ieltan> `string` is Nim's own managed string type
11:42:43FromDiscord<.aingel.> Yeah I want to use that
11:42:46FromDiscord<.aingel.> I want to use nim types
11:42:49FromDiscord<.aingel.> In my wrapped function
11:43:17FromDiscord<.aingel.> I'm just passing a void pointer I don't have to use c types for this afaik
11:43:46FromDiscord<vindaar> In reply to @heysokam "that makes `codeRT` just": Sorry, you need to be more clear about what you actually want. I thought you wanted a string representation of your code.
11:43:50FromDiscord<vindaar> Anyway I'll be away in 5 min
11:43:54FromDiscord<odexine> @Phil seems like it’s all green for you to use the free function you found https://docs.gtk.org/gtk4/question_index.html
11:43:59FromDiscord<ieltan> In reply to @.aingel. "I want to use": I don't think it's really trivial
11:44:00FromDiscord<sOkam! 🫐> In reply to @vindaar "Sorry, you need to": yes i do, but then I want to read it back too
11:44:03FromDiscord<odexine> See “memory management” portion
11:44:11FromDiscord<vindaar> In reply to @heysokam "yes i do, but": why would you want that?
11:44:11FromDiscord<ieltan> Let me look this up
11:44:28FromDiscord<sOkam! 🫐> In reply to @vindaar "why would you want": because of development testing an ast interpreter
11:44:33FromDiscord<.aingel.> In reply to @ieltan "Let me look this": That doesn't make sense to me then
11:44:40FromDiscord<Phil> In reply to @odexine "<@180601887916163073> seems like it’s": Oh thank god
11:44:41FromDiscord<sOkam! 🫐> i want to have symbols, but also string-to-ast
11:44:42FromDiscord<demotomohiro> In reply to @.aingel. "` var nodes": It probably correct as long as ctx points to vaild `seq[string]`.
11:44:50FromDiscord<Phil> I was on my third SO question by now
11:45:19FromDiscord<.aingel.> In reply to @demotomohiro "It probably correct as": Yeah, well I am getting ctx as addr seq[string]
11:45:30FromDiscord<vindaar> In reply to @heysokam "because of development testing": Then just use the AST directly from the macro? I don't quite understand.
11:45:41FromDiscord<.aingel.> `var a: seq[string]`↵`ctx = addr a`
11:45:50FromDiscord<sOkam! 🫐> In reply to @vindaar "Then just use the": the ast from the macro gives you a symbol `NimNode` not a `procdef`
11:46:01FromDiscord<.aingel.> (edit) "addr a`" => "cast[pointer](addr a)`"
11:46:03FromDiscord<sOkam! 🫐> (edit) "`procdef`" => "`nnkProcDef` as it should"
11:46:08FromDiscord<odexine> In reply to @isofruit "I was on my": Literally searched "gtk4 string free" though
11:46:14FromDiscord<.aingel.> @demotomohiro Does that make sense?
11:46:17FromDiscord<sOkam! 🫐> (edit) "In reply to @vindaar "Then just use the": the ast from the macro gives you a ... symbol" added "`nnkSymbol`"
11:46:19FromDiscord<vindaar> In reply to @heysokam "the ast from the": you need to use `getImpl` and friends on the symbol to get the implementation
11:46:37FromDiscord<sOkam! 🫐> In reply to @vindaar "you need to use": but getImpl doesn't work on that astToStr node
11:46:57FromDiscord<.aingel.> It sort of works, like it compiles and runs, but it doesn't seem to "keep" the memory
11:47:11FromDiscord<.aingel.> That function runs multiple times but it's like the seq gets reset each time
11:47:44FromDiscord<vindaar> In reply to @heysokam "but getImpl doesn't work": `astToStr` returns a string. You mean after using `parseExpr` on _that_ string?
11:47:46FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GD1
11:48:03FromDiscord<sOkam! 🫐> In reply to @vindaar "`astToStr` returns a string.": yeah
11:48:32FromDiscord<demotomohiro> In reply to @.aingel. "<@288750616510201856> Does that make": Yes. But you have to make sure that it variable `a` still exists on stack when dereference.
11:48:42FromDiscord<Phil> In reply to @odexine "Literally searched "gtk4 string": I bow to your google fu then, you got me this time
11:48:55FromDiscord<Phil> Maybe formulating it as a question was not the smartest move
11:49:06FromDiscord<.aingel.> In reply to @demotomohiro "Yes. But you have": Yeah it does still exist
11:49:28FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GD2
11:49:32FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GD3
11:50:20FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GD4
11:50:26FromDiscord<sOkam! 🫐> its returning something else
11:50:45FromDiscord<vindaar> sorry, ping me with your entire code and I'll look at it later
11:51:19*derpydoo quit (Ping timeout: 264 seconds)
11:52:08FromDiscord<ieltan> In reply to @.aingel. "That function runs multiple": My guess is that `seq` is destroyed everytime the function finishes (Nim has RAII) so you'll need something else that isn't destroyed
11:52:41FromDiscord<ieltan> Something like `uncheckedArray[string]` would maybe do the job?
11:53:22FromDiscord<ieltan> Also still not sure how to convert a `cstring` to `string` apart from casting
11:53:41FromDiscord<.aingel.> In reply to @ieltan "Also still not sure": That is not an issue
11:53:53FromDiscord<.aingel.> Idk why you think that's an issue thoguh
11:54:03FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GD6
11:55:25FromDiscord<.aingel.> In reply to @.aingel. "Idk why you think": Oh maybe it is an issue for uncheckedarray
11:55:29FromDiscord<.aingel.> (edit) "uncheckedarray" => "UncheckedArray"
11:56:46FromDiscord<.aingel.> I can't assign an uncheckedarray to a var
11:58:44FromDiscord<toma400> sent a code paste, see https://play.nim-lang.org/#ix=4GDb
11:58:56FromDiscord<demotomohiro> In reply to @.aingel. "That function runs multiple": If seq was declared in proc as local variable, it is freed when exit the proc and recreated when the proc called again.
11:59:15FromDiscord<ieltan> In reply to @.aingel. "I can't assign an": Eh.. My bad, it should be `ptr uncheckedArray[string]` I think
12:02:08FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GDd
12:04:14FromDiscord<_gumbercules> cstrings are just pointers
12:04:21FromDiscord<demotomohiro> In reply to @isofruit "Could I get a": Doesnt your `=copy` copy content of source string to dest?
12:04:21FromDiscord<_gumbercules> you shouldn't need to destroy them
12:04:23FromDiscord<sOkam! 🫐> In reply to @toma400 "I still can't get": `category name kind output` -> `var thing :MyType= 42`↵`:` is noise that belongs to the kind↵ They are indicators of properties of the kind and have nothing to do with the name↵I'm just the only weirdo that thinks this way, and as such not understood here at all. But it does make a lot of sense
12:04:50FromDiscord<Phil> In reply to @_gumbercules "you shouldn't need to": They come from gtk which instructs me that I need to take care of freeing that memory
12:04:59FromDiscord<Phil> So I do via destroy hook
12:05:19FromDiscord<_gumbercules> okay I guess if that's what GTK is telling you to do...
12:05:33FromDiscord<_gumbercules> but yeah @demotomohiro has a good point re> your copy
12:05:38FromDiscord<_gumbercules> your not actually copying anything
12:05:44FromDiscord<_gumbercules> you're just copying the pointers
12:05:47FromDiscord<Phil> In reply to @demotomohiro "Doesnt your `=copy` copy": It should copy the contents... which I guess it doesn't, right, copying refs
12:05:59FromDiscord<Phil> ` dest[] = source[]` I think?
12:06:01FromDiscord<_gumbercules> you need to know the size of the memory you want to copy
12:06:19FromDiscord<_gumbercules> I don't think that will work - I think you need `copyMem`
12:06:35FromDiscord<_gumbercules> and again the number of bytes to copy
12:06:41FromDiscord<demotomohiro> In reply to @isofruit "Could I get a": if I understand correctly, if you dont copy content of string in `=copy`, it might cause free after use.
12:07:09FromDiscord<_gumbercules> try `dest[] = source[]` but I don't think th at will work - maybe
12:07:23FromDiscord<_gumbercules> (edit) "th at" => "that"
12:07:37FromDiscord<Phil> sent a long message, see http://ix.io/4GDe
12:08:19FromDiscord<_gumbercules> I wouldn't do this this way then
12:08:25FromDiscord<_gumbercules> I'd wrap `g_free`
12:08:32FromDiscord<_gumbercules> and just use `cstring` instead of a `distinct cstring`
12:08:52FromDiscord<_gumbercules> if you want to wrap another type around the GTK type that calls `g_free` for you that's fine
12:08:59FromDiscord<Phil> In reply to @_gumbercules "and just use `cstring`": That I don't wanna do because I don't want to do this to all cstrings, there are a couple functions that return cstring where you don't free
12:09:23FromDiscord<_gumbercules> mmm
12:10:02FromDiscord<_gumbercules> well give what you have a shot and see what happens
12:10:12FromDiscord<_gumbercules> and add the `dest[] = src[]` bit
12:10:21FromDiscord<_gumbercules> worst that can happen is you will segfault and then figure out what to do
12:10:32FromDiscord<Phil> In reply to @demotomohiro "if I understand correctly,": That is correct, I'll see what else I can do here
12:10:39FromDiscord<Phil> Okay, time to see what blows up on me
12:10:58FromDiscord<Phil> Or rather adjust all the procs that give me cstring to give me GtkString instead
12:11:00FromDiscord<_gumbercules> if you don't pass these strings back and forth between Nim and GTK you might be okay
12:11:05FromDiscord<Phil> or I guess "OwnedGtkString" or sth
12:11:21FromDiscord<.aingel.> In reply to @demotomohiro "If seq was declared": I'm not trying to create it though, just deref the pointer
12:11:25FromDiscord<_gumbercules> if you do - I'm guessing you'll run into issues with Nim's gc trying to destroy something that is still referenced on the C side or vis versa
12:11:39FromDiscord<.aingel.> How can I access it via dereffing it without getting the gc to act on it
12:12:19FromDiscord<sOkam! 🫐> Is it not possible to get a `nnkSym` from `astToStr( myProc ).parseExpr()`?↵I'm getting a `nnkIdent` but I need a symbol for `getImpl`↵Is it possible to do this in some way?
12:14:07*jmdaemon quit (Ping timeout: 244 seconds)
12:14:59FromDiscord<_gumbercules> In reply to @.aingel. "How can I access": if you don't want the GC to manage the memory behind the seq then manually allocate the memory yourself and dispose of it yourself
12:15:14FromDiscord<.aingel.> In reply to @_gumbercules "if you don't want": I don't mind the GC managing it when I create it
12:15:31FromDiscord<_gumbercules> the GC isn't doing anything when you deref and access the value
12:15:33FromDiscord<.aingel.> So I create it in one proc, then pass the addr to a second proc
12:15:34FromDiscord<sirolaf> In reply to @heysokam "Is it not possible": https://nim-lang.org/docs/macros.html#bindSym%2C%2CBindSymRule
12:15:41FromDiscord<.aingel.> In reply to @_gumbercules "the GC isn't doing": Thats what i would think to
12:15:42FromDiscord<_gumbercules> right but as soon as that first proc ends
12:16:02FromDiscord<.aingel.> In reply to @_gumbercules "right but as soon": It ends only after the callbacks have been called
12:16:18FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GD3
12:16:27*junaid_ quit (Remote host closed the connection)
12:16:28FromDiscord<_gumbercules> hold on
12:16:45FromDiscord<.aingel.> So the callbacks triggered by lxb_selectors_find call , and then print nodes gets called
12:16:46FromDiscord<_gumbercules> you're passing a reference via `cast[pointer](addr nodes)` and the GC isn't aaware you're doing this
12:16:58FromDiscord<.aingel.> Thats cool I dont want it to know
12:17:06FromDiscord<_gumbercules> okay so think about it then
12:17:14FromDiscord<_gumbercules> the GC doesn't know you've essentially created a ref
12:17:18FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GDg
12:17:22FromDiscord<_gumbercules> at the end of the first proc
12:17:31FromDiscord<.aingel.> Whats the first proc
12:17:35FromDiscord<.aingel.> The calling proc right
12:17:38FromDiscord<_gumbercules> the proc where you declare the sequence
12:17:39FromDiscord<Phil> That is inim, no hook defined
12:17:43FromDiscord<.aingel.> Sure
12:17:51FromDiscord<_gumbercules> it's' going to say - okay this sequence isn't referenced anymore anywhere - I should destroy it
12:17:59FromDiscord<_gumbercules> because the GC doesn't know you passed an unsafe ref around somewhere
12:18:03FromDiscord<.aingel.> But the second proc has already been called
12:18:31FromDiscord<_gumbercules> I don't know what the second procedure is doing with that sequence
12:18:40FromDiscord<_gumbercules> so I can't really say what the code you're calling into is doing with it
12:18:43FromDiscord<.aingel.> Doesnt mater though it's already called it
12:18:46FromDiscord<_gumbercules> yes it does
12:19:00FromDiscord<_gumbercules> because if it takes that reference and then passes it around or stores it and tries to access it later
12:19:03FromDiscord<_gumbercules> and the memory has been collected
12:19:05FromDiscord<.aingel.> Thats fine
12:19:09FromDiscord<.aingel.> Thats not happening though
12:19:13FromDiscord<_gumbercules> what is the problem then?
12:19:32FromDiscord<.aingel.> I'm saying the order of operation is proc1 call starts, proc 2 gets called three times or so, then proc1 ends
12:19:38FromDiscord<.aingel.> So the order of operation is fine
12:19:47FromDiscord<_gumbercules> thats' not really how CPUs work but regardless, what is the problem
12:20:14FromDiscord<_gumbercules> in terms of stack frames sure in terms of what instructions get executed in what order, there's no guarantee there
12:20:34FromDiscord<.aingel.> Yeah well at least in terms of stack frames
12:20:43FromDiscord<.aingel.> I mean idk if anything more than that is really relevant to this
12:20:49FromDiscord<_gumbercules> what's the problem though lol
12:21:01FromDiscord<_gumbercules> I'm stil unclear about that
12:21:19FromDiscord<.aingel.> The issue is that within proc2 when I deref the pointer it always has nothing in it
12:21:29FromDiscord<.aingel.> Even thoguh I add to it and proc2 gets called mulitple times before proc1 ends
12:22:08FromDiscord<_gumbercules> I'm trying to find the original code / message
12:22:12FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GDh
12:22:15FromDiscord<.aingel.> Thats my proc2
12:22:19FromDiscord<_gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4GD3
12:22:21FromDiscord<_gumbercules> okay
12:22:30FromDiscord<.aingel.> My proc2 is the callback basically
12:22:36FromDiscord<.aingel.> triggered by selectors_find
12:22:41FromDiscord<_gumbercules> so `lxb_selectors_find` is supposed to populate the sequence?
12:22:43FromDiscord<.aingel.> Each time I print nodes it's just meow
12:22:49FromDiscord<.aingel.> In reply to @_gumbercules "so `lxb_selectors_find` is supposed": Yeah
12:22:59FromDiscord<.aingel.> If I increment a global var and print it
12:23:00FromDiscord<_gumbercules> what does `findcb` do?
12:23:02FromDiscord<.aingel.> It increments
12:23:09FromDiscord<.aingel.> It gets triggere
12:23:11FromDiscord<.aingel.> (edit) "triggere" => "triggered"
12:23:18FromDiscord<.aingel.> It's a callback for that selector function
12:23:23*junaid_ joined #nim
12:23:27FromDiscord<.aingel.> So actually selectors find doesnt populate it, its findcd
12:23:29FromDiscord<.aingel.> (edit) "findcd" => "findcb"
12:23:35FromDiscord<_gumbercules> no I get that but can you paste its implementation?
12:23:38FromDiscord<.aingel.> But selectors_find triggers findcb
12:23:42FromDiscord<.aingel.> No i cant its a c func
12:24:03FromDiscord<_gumbercules> yeah there's too much interop going on here to really reason about what's wrong with your code
12:24:05FromDiscord<sOkam! 🫐> In reply to @sirolaf "https://nim-lang.org/docs/macros.html#bindSym%2C%2C": I'm getting `string literal expected` now when doing `strCode.parseExpr().bindSym()`
12:24:18FromDiscord<.aingel.> I dont think it really matters though
12:24:21FromDiscord<_gumbercules> I'd need to see some C code as well
12:24:22FromDiscord<_gumbercules> it does
12:24:32FromDiscord<.aingel.> Okay if u say so
12:24:40FromDiscord<_gumbercules> because obviously it's not working and the Nim code you've shown isn't enough to understand the root cause of the issue
12:25:15FromDiscord<_gumbercules> without seeing `find_cb` and `lxb_selectors_find` it's gong to be difficult for anyone to reason about why your code isn't doing what you expect it to do
12:26:02FromDiscord<_gumbercules> if you don't want to share that code or can't for whatever reason, you should probably lean on address sanitizer or Valgrind
12:26:32FromDiscord<.aingel.> Idk
12:27:01FromDiscord<.aingel.> I feel like you're jumping instantly to there being something going on in the c code
12:27:34FromDiscord<_gumbercules> I'm not jumping anywhere but you've shared 3 lines of Nim code that are doing interop with C - how you expect anyone to troubleshoot an issue when you've shared three lines of code that call into who knows what other code is beyond me
12:27:43FromDiscord<.aingel.> Just assume that its just passing the pointer
12:27:54FromDiscord<.aingel.> And not doing anything weird with it
12:28:05FromDiscord<ieltan> I don't think the casting here is sane anyways with the pointer being represented as a `ptr seq[string]` it probably does not do what you want
12:28:07FromDiscord<.aingel.> This is a widely used library I am pretty sure it's just passing the ctx pointer
12:28:28FromDiscord<.aingel.> In reply to @ieltan "I don't think the": Can u explain pls
12:28:34FromDiscord<_gumbercules> Nim strings are not C strings
12:29:15FromDiscord<.aingel.> Okay and
12:29:27FromDiscord<.aingel.> I just want to pass a generic pointer
12:29:56FromDiscord<ieltan> In reply to @.aingel. "Can u explain pls": Because `string` is a complex object, merely casting a pointer to it doesn't mean it will just "work"
12:29:57FromDiscord<_gumbercules> that's not the point
12:30:05FromDiscord<_gumbercules> you're passing a pointer to a sequence of Nim strings
12:30:17FromDiscord<_gumbercules> and then you're apparently creating Nim strings in your C code and populating that sequence with them?
12:30:22FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GDj
12:30:23FromDiscord<_gumbercules> that's not going to work....
12:30:26FromDiscord<.aingel.> In reply to @_gumbercules "and then you're apparently": No i am not
12:30:29FromDiscord<sOkam! 🫐> so if you are mapping regular C, that is going to fail
12:30:30FromDiscord<.aingel.> It's all nim code
12:30:43FromDiscord<ieltan> In reply to @heysokam "<@1152336447467163790> I don't know": Yeah I've been looking for this code snippet lol
12:30:45FromDiscord<_gumbercules> you said earlier that your callback was written in C
12:30:51FromDiscord<.aingel.> No
12:30:58FromDiscord<.aingel.> The function that triggers the callback is in c
12:31:02FromDiscord<.aingel.> But the callback is in nim
12:31:10FromDiscord<sOkam! 🫐> In reply to @ieltan "Yeah I've been looking": https://nim-lang.org/docs/destructors.html
12:31:15FromDiscord<_gumbercules> okay well - again it's going to be difficult for me to debug this with only seeing three lines of code
12:31:21FromDiscord<_gumbercules> my baby is awawke and crying so I gotta go get him
12:31:29FromDiscord<.aingel.> okay thanks for the help!
12:31:34FromDiscord<sOkam! 🫐> In reply to @.aingel. "But the callback is": then why are you casting at all?↵casting is the most unsafe thing you can do in nim
12:31:42FromDiscord<sOkam! 🫐> if the data is from nim, don't cast
12:31:44FromDiscord<sOkam! 🫐> convert it
12:32:02FromDiscord<sOkam! 🫐> even if the data is from C you should convert it in a proc, not cast it
12:32:16FromDiscord<.aingel.> Because the callback is triggered through C
12:32:20FromDiscord<.aingel.> and it takes a void pointer
12:32:27FromDiscord<.aingel.> But the callback implementation is in nim
12:32:35FromDiscord<sOkam! 🫐> so you are sending a ptr seq to C?
12:32:39FromDiscord<.aingel.> Yes
12:32:44FromDiscord<.aingel.> And it calls a callback which is in nim
12:32:51FromDiscord<.aingel.> Which takes a `pointer`
12:32:55FromDiscord<.aingel.> As the argument
12:33:12FromDiscord<.aingel.> Thats why I need to cast it
12:33:25FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GDk
12:33:42FromDiscord<sOkam! 🫐> In reply to @.aingel. "Which takes a `pointer`": any pointer in nim is compatible with `pointer`. you dont need to cast them
12:33:43FromDiscord<ieltan> Does C even understand what a `seq` is? you would have to send it an `uncheckedArray` if it doesn't
12:33:54FromDiscord<.aingel.> I dont even want this to be a seq[string] eventually, I'm just using this as a placeholder for now
12:33:55FromDiscord<ieltan> ptr
12:34:01FromDiscord<sOkam! 🫐> In reply to @ieltan "Does C even ": it doesn't, and all you need to send is a ptr to the first entry of the data
12:34:02FromDiscord<.aingel.> I want it to be a seq of some other generic type
12:34:31FromDiscord<.aingel.> In reply to @heysokam "any pointer in nim": Okay that helps
12:34:48FromDiscord<sOkam! 🫐> also, you need to convert to `cstringArray` before sending to C, otherwise if its a nim string it wont work
12:34:55FromDiscord<.aingel.> But still have the problem of when I deref it seems to be empty everytime
12:35:01FromDiscord<ieltan> Ok, first of all, you need to make this work at a low level and then make a high level interface so that users don't have to work with unsafe data
12:35:07FromDiscord<.aingel.> In reply to @heysokam "also, you need to": I dont even want this to be a string
12:35:27FromDiscord<ieltan> If you don't make it work at a low level first then don't bother trying to pass seqs and strings and whatnot
12:35:51FromDiscord<sOkam! 🫐> In reply to @.aingel. "I dont even want": I'm missing some context:↵1. whats your input?↵2. whats your output?↵3. whats the shape of the C function you are sending your data to?
12:37:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GDm
12:38:08FromDiscord<ieltan> So much C interoopin today 🤔
12:39:52FromDiscord<Phil> The fact that I'm part of the C interoopin crew is still mildly nuts to me
12:42:09FromDiscord<_gumbercules> I'm back
12:42:19FromDiscord<_gumbercules> In reply to @ieltan "So much C interoopin": this is most of my code
12:49:28FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GDq
12:49:44FromDiscord<_gumbercules> In reply to @isofruit "Okay I got further": yeah I got to the `.pop` thing just now
12:50:14FromDiscord<Phil> I mean the examples compile without the copy hook and the one app-example in owlkettle where I can test it works fine
12:50:24FromDiscord<_gumbercules> looking
12:50:25FromDiscord<Phil> I put an echo in the destroy hook and it gets called as it shoul
12:50:26FromDiscord<Phil> (edit) "shoul" => "should"
12:51:02FromDiscord<Phil> I'm tempted to ask #internals if this is a compiler bug
12:52:08FromDiscord<Phil> Because the error disappears if:↵A) You don't use {.pop.} or↵B) You don't have a destroy hook or↵C) You don't have a copy hook (well that one is self-explanatory)
12:52:24FromDiscord<Phil> It makes no sense that the combo of {.pop.} with a destroy hook somehow leads to the creation of a copyhook
12:54:45FromDiscord<_gumbercules> maybe?
12:54:47FromDiscord<_gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4GDs
12:55:20FromDiscord<_gumbercules> I think what was leading to the creation of the copy hook was the conversion of your distinct type back to `cstring` and `pointer`
12:55:55FromDiscord<_gumbercules> I guess the copy hook from cstring gets included in the C code to perform the conversion
12:59:01FromDiscord<Phil> Is there a way where I don't tie g_free to OwnedGtkString? There may be other calls to g_free with other types in the future
12:59:50FromDiscord<Phil> Well, I guess I can just leave out the copy, if it basically uses the cstring copy hook I'm fine
13:26:01*blackbeard420 quit (Quit: ZNC 1.8.2 - https://znc.in)
13:26:14*blackbeard420 joined #nim
13:41:42FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GDH
13:57:05*ntat joined #nim
14:19:31FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4GDR
15:24:56*ntat quit (Quit: leaving)
15:25:42*krux02 joined #nim
15:30:24FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4GEk
15:35:00FromDiscord<odexine> youre pretty much asking for the whole compiler's source at that point you know
15:35:15FromDiscord<odexine> what else is a compiler other than something that reads files and then generates something out of it
15:35:34FromDiscord<odexine> can you specify more about what you're aiming for
15:48:55FromDiscord<sOkam! 🫐> In reply to @odexine "can you specify more": Writing a compiler for nim code, that generates different code than C
15:49:12FromDiscord<sOkam! 🫐> there is probably a better explanation for that, using more compiler-correct terms, but that's my goal
15:50:04FromDiscord<sOkam! 🫐> You can think of it, in simpler terms, like what `treeform/shady` does, but at runtime with the compiler as a library... not at compiletime through macros/metaprogramming
15:51:17FromDiscord<sOkam! 🫐> In reply to @odexine "youre pretty much asking": Yeah I understand. That's basically the goal↵I just want to get the AST that the compiler itself is using to codegen, but do something with it in a different way than what the nimc codegen section does
15:53:28FromDiscord<Phil> Curiosity question: is it basically mandatory in c libs to provide functions that can free all the various data your lib provides?
15:54:02FromDiscord<odexine> In reply to @isofruit "Curiosity question: is it": yes
15:54:26FromDiscord<odexine> allocate and deallocate (malloc and free) are bound to the allocator
15:54:45FromDiscord<odexine> if you allocate memory with one allocator and deallocate it with another allocator then 💥
15:55:51FromDiscord<Phil> Does every program provide its own instance of an allocator?
15:57:11FromDiscord<Chronos [She/Her]> In reply to @heysokam "Writing a compiler for": Pass `--path:"$nim"` to the compiler, and make sure you define `nimcore`, but you'll suffer immensely :p
15:57:11FromDiscord<odexine> no, most programs usually just use regular malloc/free
15:57:30FromDiscord<Chronos [She/Her]> Using compiler libraries after that is just `import compiler/insertLibraryHere`
15:57:38FromDiscord<Chronos [She/Her]> You will suffer
15:57:40FromDiscord<Phil> And "regular malloc/free" is provided by the os?
15:57:54FromDiscord<odexine> either that or a dynamic library
15:58:04FromDiscord<odexine> this can also be overridden
15:58:21FromDiscord<Chronos [She/Her]> In reply to @chronos.vitaqua "You ***will*** suffer": Look at compiler/jsgen.nim
15:59:00FromDiscord<Phil> So there an allocator comes from is kind of wild west: there's a standard and a lot of things follow it but enough variance that you can never rely on that
15:59:05FromDiscord<sOkam! 🫐> In reply to @chronos.vitaqua "You ***will*** suffer": I cannot, if I don't know how to read the file into an AST
15:59:07FromDiscord<Phil> (edit) "there" => "where"
16:01:57FromDiscord<sOkam! 🫐> I've been reading the ast/parser/etc files... but all of those are used on already existing data that is coming from somewhere↵My question is how to find where that somewhere comes from, since the files must be read somewhere by the compiler
16:01:59FromDiscord<odexine> In reply to @isofruit "So where an allocator": basically the rule is: allocation functions pair with free functions. if you're using malloc/free, no problem in any case
16:02:18FromDiscord<odexine> if you're using a custom allocator then they should be paired too ofc
16:03:00FromDiscord<Chronos [She/Her]> In reply to @heysokam "I've been reading the": Should come from somewhere in main.nim or nim.nim in the compiler folder
16:03:19FromDiscord<sOkam! 🫐> yeah but main is huge
16:05:12FromDiscord<Chronos [She/Her]> I mean... If you want to do what you want, gotta do the effort :p
16:06:44*xaltsc quit (Ping timeout: 245 seconds)
16:08:16FromDiscord<sOkam! 🫐> In reply to @chronos.vitaqua "I mean... If you": I think the issue is that the data for main is not coming from main, its coming from nim.nim
16:08:28FromDiscord<sOkam! 🫐> that's what was throwing me off
16:09:16FromDiscord<sOkam! 🫐> the file seems to be read into a ModuleGraph object, and that happens at nim.nim and sent to main
16:53:12*rockcavera joined #nim
16:53:43*def- quit (Quit: -)
16:54:11FromDiscord<sOkam! 🫐> I think I found it by reading the nimpretty section↵They key seems to be in `parseAll()`. That function returns a PNode, which seems to be the root of the AST ✍️↵So its all a matter of reading the file into a parser object (haven't figured out how) and then use the resulting PNode
16:54:27*def- joined #nim
17:03:41*junaid_ quit (Remote host closed the connection)
17:06:23FromDiscord<.aingel.> okay so my code works if I do ↵` (cast[ptr seq[string]](ctx))[].add("meow")` ↵but not if I do
17:06:40FromDiscord<.aingel.> ` var foo = (cast[ptr seq[string]](ctx))[]`↵` foo.add("meow")`
17:06:47FromDiscord<.aingel.> Basically when I put it to a var, it seems to create a copy of it
17:06:57FromDiscord<.aingel.> Instead of just working with the data in the pointer
17:06:59FromDiscord<Elegantbeef> Strings are value types so, yes
17:07:07FromDiscord<.aingel.> It's not a string though
17:07:13FromDiscord<Elegantbeef> well seqs and strings
17:07:21FromDiscord<.aingel.> But it works if I don't assign to var
17:07:27FromDiscord<Elegantbeef> remove the dereference and move it to `foo[].add`
17:07:45FromDiscord<.aingel.> Oh I see
17:07:48FromDiscord<.aingel.> Yeah that makes sense
17:08:09FromDiscord<Elegantbeef> Yes cause dereferencing creates an L-value
17:08:27FromDiscord<.aingel.> Gotcha
17:08:32FromDiscord<.aingel.> Yeah your way works great
17:08:37FromDiscord<sOkam! 🫐> actually, nvm. its not `parseAll` its `parseString`!! Literally what I needed 🥳
17:08:39FromDiscord<.aingel.> What's an L-value?
17:08:50FromDiscord<Elegantbeef> In the single line the `[]` emits `var seq[string]` in the later way you copy the seq due to storing to a variable
17:09:09FromDiscord<Elegantbeef> It's a C++ term, `L-Value` practically means a writeable expression
17:09:15FromDiscord<.aingel.> Oh okay
17:09:41FromDiscord<.aingel.> Right and then it assigns it to a new var if I do the deref before the add
17:09:44FromDiscord<.aingel.> Makes sense, thank you!
17:11:20FromDiscord<raynei486> In reply to @Elegantbeef "It's a C++ term,": ackchually it's something that's addressable 🤓🤓
17:13:57FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GEU
17:15:03*dza quit (Server closed connection)
17:16:28*dza joined #nim
17:20:39FromDiscord<odexine> you're on inim
17:20:46FromDiscord<odexine> it recompiles the file every expression
17:21:02FromDiscord<odexine> use a real file and see that the pointer is the same
17:21:22FromDiscord<odexine> @Phil
17:21:56FromDiscord<Phil> Dangit
17:22:23FromDiscord<odexine> next time to verify equality use a single expression
17:22:38FromDiscord<odexine> echo x.pointer.repr, " ", y.pointer.repr
17:22:42FromDiscord<odexine> or == if you want
17:27:55*ntat joined #nim
17:37:06FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4GEZ
17:40:35FromDiscord<odexine> Can’t help you there
17:54:06*ntat quit (Quit: leaving)
18:01:19FromDiscord<Elegantbeef> Phil we went overthis
18:01:20FromDiscord<Elegantbeef> First usage generates hooks, you need to declare hooks before any code
18:01:33rockcaveraI was wondering which of the three procedures provides the best performance for a constructor? I verified that in all cases the generated C code is different. https://play.nim-lang.org/#ix=4GF8
18:02:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4GF9
18:03:04FromDiscord<Elegantbeef> Who cares about the generated C, look at the ASM
18:03:09FromDiscord<Elegantbeef> Alternatively benchmark it
18:04:08rockcaveranewMyRef1() gives a smaller asm
18:04:23FromDiscord<can.l> In reply to @Elegantbeef "<@180601887916163073>\: This compiles but": Might be the issue we had before, so maybe we need a `=sink`. It is also very much possible that `g_free` is just the "wrong `free` proc" for the given pointer.
18:04:51FromDiscord<Elegantbeef> With `-d:release -d:lto`
18:04:51FromDiscord<Elegantbeef> ?
18:06:04FromDiscord<Elegantbeef> `g_free` is completely wrong in hindsight
18:06:04FromDiscord<Elegantbeef> `"lala"` is a constant cstring which resides in `.data`
18:06:14FromDiscord<Elegantbeef> Freeing it is 100% incorrect behaviour
18:09:22FromDiscord<Phil> In reply to @Elegantbeef "Freeing it is 100%": That code example is more to demonstrate the double copy
18:09:28FromDiscord<Phil> (edit) "In reply to @Elegantbeef "Freeing it is 100%": That code example is more to demonstrate the double copy ... " added "proc problem"
18:09:35FromDiscord<Phil> Which comes into play because =destroy exists
18:10:11FromDiscord<Phil> In reply to @can.l "Might be the issue": And that one is not the case.↵At least not based on gtk's own docs
18:10:27FromDiscord<Elegantbeef> I mean in this case `g_free` is 100% wrong so what?
18:10:45FromDiscord<Chronos [She/Her]> Time to work on my Java backend again
18:11:48FromDiscord<Phil> In reply to @Elegantbeef "I mean in this": ? The main reason I have the code as it is is to get an example close-ish to what I face in owlkettle.↵In the "real" example the string would be coming from a proc stemming from gtk where g_free definitely is the right choice. Just no clue how I'd simulate that here
18:14:21FromDiscord<Phil> sent a long message, see http://ix.io/4GFd
18:14:26FromDiscord<Phil> (edit) "http://ix.io/4GFd" => "http://ix.io/4GFe"
18:15:36FromDiscord<Chronos [She/Her]> `of '\l': result.add("\\n")` huh
18:17:01FromDiscord<Phil> Erm... how do you copy a cstring
18:17:25FromDiscord<Phil> it's not a ref type so `[]` to unref seems a tad weird
18:22:38FromDiscord<Phil> Heck how the hell do I even define the copy proc without making it recursive
18:26:22FromDiscord<Phil> In reply to @can.l "Might be the issue": Running into the entire recursive copying issue again that is starting to become mildly frustrating to deal with, particularly for this cstring bit since I have no clue how one is supposed to copy a cstring when you can't unref, you can't copymem because you can't know the size of the string and you can't just assign because that makes things recursive
18:27:56*junaid_ joined #nim
18:31:10rockcaverain a small benchmark newMyRef1() seems faster: https://play.nim-lang.org/#ix=4GFi
18:38:25*def- quit (Quit: -)
18:38:38*def- joined #nim
18:41:06NimEventerNew question by Philipp Doerner: How do you copy the value of a cstring in nim?, see https://stackoverflow.com/questions/77123150/how-do-you-copy-the-value-of-a-cstring-in-nim
18:41:33NimEventerNew thread by Isofruit: How to define a =copy hook for a distinct cstring type?, see https://forum.nim-lang.org/t/10490
18:43:58*lucasta joined #nim
18:45:04FromDiscord<Phil> Wait a second.... @can.l do we even need a copy-hook for the OwnedGtkString type?
18:45:48FromDiscord<Phil> We originally only needed one for Pixbuf because simple assignment stuff wouldn't compile otherwise.↵With the cstring stuff... well you get a copy of the pointer, though not the value
18:48:15FromDiscord<Chronos [She/Her]> Yeah okay I'm better off making my own language oof
18:50:44*lucasta quit (Remote host closed the connection)
18:51:08*lucasta joined #nim
18:51:09*lucasta quit (Remote host closed the connection)
18:51:37NimEventerNew thread by MattRixman: Is there a `terminal.setRaw` on Linux?, see https://forum.nim-lang.org/t/10491
18:57:14*disso-peach joined #nim
19:00:36*disso-peach quit (Client Quit)
19:11:47FromDiscord<nomad> sent a code paste, see https://play.nim-lang.org/#ix=4GFo
19:17:43FromDiscord<nnsee> you're missing a dash
19:18:39FromDiscord<nnsee> it's `--app`, not `-app`
19:18:57FromDiscord<nnsee> the latter would be parsed as `-a -p -p`
19:19:08FromDiscord<nnsee> which is why you're getting that error
19:26:35FromDiscord<can.l> In reply to @isofruit "Running into the entire": Since you need something allocated by GTK (in order to use `g_free`), you can just use https://developer-old.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup
19:30:04FromDiscord<can.l> In reply to @isofruit "Wait a second.... <@893965307171979326>": The question is if Nim just silently uses the wrong `=copy` if none is defined, or if it errors out. Judging from your GH comment, it just silently uses the wrong hook. That is a problem from a software maintenance perspectice, since even if we could verify that no `=copy` is called in the current version, it is basically expected that this will be forgotten about in the fut
19:36:20FromDiscord<nomad> In reply to @nnsee "it's `--app`, not `-app`": thanks man, i would never have noticed that 😭
19:37:16FromDiscord<Phil> In reply to @can.l "The question is if": I think I've got it now, example on the PR
19:51:51*junaid_ quit (Remote host closed the connection)
20:14:25*xmachina quit (Quit: WeeChat 4.0.4)
20:42:12FromDiscord<Elegantbeef> @Phil reading your PR a bit, might be a case of cursors causing your copies not to be made
20:42:31FromDiscord<Phil> And a cursor is what?
20:42:31FromDiscord<Elegantbeef> Though these are pointers so it should probably always copy
20:43:19FromDiscord<Elegantbeef> A cursor is a copy elision, instead of making a copy of a variable the compiler is free to just alias a pointer to that variable if the logic is still correct
20:43:48FromDiscord<Elegantbeef> https://nim-lang.org/docs/destructors.html#the-cursor-pragma
20:43:59FromDiscord<Elegantbeef> https://nim-lang.org/docs/destructors.html#cursor-inference-slash-copy-elision
20:43:59FromDiscord<Phil> elision = leaving sth out?
20:44:03FromDiscord<Elegantbeef> Whoops wrong manual
20:44:04FromDiscord<Elegantbeef> Yes
20:44:16FromDiscord<Elegantbeef> Copy elision is fancy talk for "Skipping a copy"
20:44:45FromDiscord<Elegantbeef> This of course depends on what you're doing
20:45:00FromDiscord<_gumbercules> added some jolt physics to my wasm gane engine project thing https://media.discordapp.net/attachments/371759389889003532/1153069114642923571/chrome_W5jOusyAUN.mp4
20:45:27FromDiscord<Elegantbeef> Nice, I have expected the human to turn into jelly on collision
20:45:30FromDiscord<Elegantbeef> half\
20:46:18FromDiscord<Elegantbeef> What shadow technique are you using?
20:46:54FromDiscord<Elegantbeef> Cannot tell if it's artifacting but seems the shadow eases out when it's not touching the ground
20:48:02FromDiscord<Phil> Ah, good point on the cursor thingy: Managed to trigger a copy by doing assignment to a var and then a let variable as that tends to work in these cases
20:48:23FromDiscord<_gumbercules> that's probably just some clipping plane / depth stuff I haven't sorted out Elegantbeef
20:48:27FromDiscord<_gumbercules> It's just regular old shadow mapping
20:48:58FromDiscord<_gumbercules> https://floooh.github.io/sokol-html5/shadows-sapp.html
20:49:00FromDiscord<_gumbercules> essentially what you see here
20:49:40*jmdaemon joined #nim
20:50:06FromDiscord<_gumbercules> In reply to @Elegantbeef "Nice, I have expected": ragdoll inc
20:52:57FromDiscord<Phil> Still can't figure out how I'd do code that triggers a sink, but hey, at least I could test the copy hook.
20:53:17FromDiscord<Elegantbeef> make a proc that takes a `sink` param
20:53:18FromDiscord<Elegantbeef> or use `move`
21:05:09*PMunch quit (Quit: leaving)
21:28:17FromDiscord<starkiller1493> Is there a simple way to copy an object?
21:33:30FromDiscord<raynei486> [deepCopy](https://nim-lang.org/docs/system.html#deepCopy%2CT)?
21:38:55FromDiscord<Elegantbeef> `var a = b`
21:39:21FromDiscord<Elegantbeef> `deepCopy` recursively copies references which might be what you want, but it's also behind a flag on Orc/Arc
21:39:29*pbsds quit (Ping timeout: 246 seconds)
21:45:34*pbsds joined #nim
21:45:45FromDiscord<starkiller1493> thanks, `deepCopy` was what I had in mind, but `var a = b` is enough
21:52:00FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "`deepCopy` recursively copies references": Why is it behind a flag?
21:52:12FromDiscord<Chronos [She/Her]> If people are using deepCopy, wouldn't they know what they're doing?
21:52:49FromDiscord<Elegantbeef> Cause it can be implemented better as a macro or proc is what Araq has said
21:53:49*xmachina joined #nim
21:54:26FromDiscord<Elegantbeef> I do really tend to talk backwards
21:56:17FromDiscord<.aingel.> When doing cinterop, if I want to access a struct member, do I have to write the whole struct def in nim?
21:56:40FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GG1
21:56:47FromDiscord<Elegantbeef> Yes, or you can use futhark to do it for you
21:56:54Amun-Rayes
21:57:02FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GG2
21:57:05FromDiscord<.aingel.> Okay yeah that will take so much of time
21:57:09FromDiscord<.aingel.> I need to get futhark runnign
21:57:12FromDiscord<.aingel.> It's not building for me
21:57:13FromDiscord<Elegantbeef> Or you can use c2nim
21:57:25FromDiscord<.aingel.> c2nim wasn't working for me either
21:57:28FromDiscord<Elegantbeef> Install libclang
21:57:33FromDiscord<.aingel.> Do you run c2nim on the header file?
21:57:37FromDiscord<.aingel.> Or the c file
21:57:37FromDiscord<Elegantbeef> yes
21:58:09FromDiscord<Elegantbeef> The header since you want the ABI not the code transpiled
21:58:51FromDiscord<.aingel.> Yeah c2nim just outputs a big comment
21:59:01FromDiscord<Elegantbeef> You likely should do \`gcc -E ./yourheader
21:59:10FromDiscord<Elegantbeef> to expand the header then remove everything that you do not need
21:59:22FromDiscord<.aingel.> okay let me try that
22:00:18FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Cause it can be": Better? How so?
22:00:26FromDiscord<Chronos [She/Her]> You mean by the users themselves?
22:00:28FromDiscord<Elegantbeef> I didnt say it
22:00:30FromDiscord<Elegantbeef> So don't ask me
22:00:40FromDiscord<Chronos [She/Her]> Welp I'm not asking Araq so-
22:00:57FromDiscord<.aingel.> I'm geetting some wild stuff outta that
22:01:42FromDiscord<Elegantbeef> Right you need to remove what isnt actually included
22:01:47FromDiscord<Elegantbeef> Rather what you don't want included
22:01:48FromDiscord<.aingel.> @ElegantBeouf Also I can't find out how to install libclang on macos
22:01:53FromDiscord<Chronos [She/Her]> Wouldn't futhark be better? :P
22:02:07FromDiscord<Elegantbeef> better is subjective afterall
22:02:12FromDiscord<Elegantbeef> futhark is generally more usable yes
22:03:37FromDiscord<Chronos [She/Her]> C2Nim requires manual editing while Futhark works quite well afaik excluding any particularly tricky stuff
22:03:59FromDiscord<.aingel.> Yeah I will try and get futhark working but I think this is a good learning experience anyways though
22:04:02FromDiscord<.aingel.> To know what exactly is going on
22:04:21FromDiscord<.aingel.> sent a code paste, see https://play.nim-lang.org/#ix=4GG4
22:04:22FromDiscord<.aingel.> Do I also need importc
22:04:29FromDiscord<Chronos [She/Her]> In reply to @.aingel. "Yeah I will try": Fair
22:05:54FromDiscord<.aingel.> I'm assuming I don't need importc then if I import the struct like this?
22:06:03FromDiscord<.aingel.> Or do I/
22:06:14FromDiscord<.aingel.> (edit) "I/" => "I"
22:07:07FromDiscord<Elegantbeef> You do not technically need to but it's good for your health to point at the header file
22:09:17FromDiscord<.aingel.> Why is it good for health
22:09:18FromDiscord<.aingel.> just curious
22:09:54FromDiscord<Elegantbeef> It includes the header and you get C's(albiet limited) type checking
22:10:53FromDiscord<Elegantbeef> Just lazily doing `gcc -E` on the dom.h then passing it to c2nim gets you something almost usable https://play.nim-lang.org/#ix=4GG5
22:11:15FromDiscord<Elegantbeef> Still issues like the inline procs not being properly written or procs not annotated with cdecl, but that sort of stuff is not too bad
22:12:04FromDiscord<Elegantbeef> Many proc pointers are also not generated, due to attributes I assume
22:12:15FromDiscord<Elegantbeef> Changing the C macro there would help
22:12:34FromDiscord<Elegantbeef> Getting libclang installed through brew and using futhark would likely be less work
22:13:05FromDiscord<.aingel.> Ya
22:13:17FromDiscord<.aingel.> I think I know enough about how it works internally now to not want to do it
22:13:46FromDiscord<.aingel.> I have /usr/local/opt/llvm/lib/libclang.dylib
22:13:48FromDiscord<Elegantbeef> Blame C for being such a silly ABI language 😄
22:13:51FromDiscord<.aingel.> haha
22:13:57FromDiscord<.aingel.> And it's in my path
22:14:04FromDiscord<Elegantbeef> So install futhark pointing it to that path
22:14:06FromDiscord<.aingel.> But nimble futhark still says cannot find
22:14:23FromDiscord<Elegantbeef> using `--passL:-L/Path/To/libclang/dir`
22:14:29FromDiscord<.aingel.> okie
22:14:36FromDiscord<Elegantbeef> https://github.com/PMunch/futhark#installation
22:14:39FromDiscord<Elegantbeef> RTFM people
22:14:40FromDiscord<Elegantbeef> I swear
22:15:00FromDiscord<.aingel.> Sorry!
22:15:52FromDiscord<.aingel.> ` Success: futhark installed successfully.`
22:15:54FromDiscord<.aingel.> Yay
22:16:23FromDiscord<Elegantbeef> Excuse me whilst I mutter under by breath about reading
22:16:45FromDiscord<.aingel.> 😆
22:26:23FromDiscord<Chronos [She/Her]> Okay old man, we get it, jeez!
22:26:46FromDiscord<Elegantbeef> Hey I'm not old, now get of my lawn
22:36:03*dv^_^ quit (Server closed connection)
22:36:28*dv^_^ joined #nim
23:00:14*disso-peach joined #nim
23:45:58*lumo_e joined #nim
23:59:42FromDiscord<millymox> Can someone direct me on how to use nim to compile js to be able to use electron?
23:59:46FromDiscord<millymox> Please