<< 06-10-2023 >>

00:03:33FromDiscord<geekrelief> @_gumbercules hi 😄
00:04:42FromDiscord<_gumbercules> In reply to @geekrelief "<@204328759715692544> hi 😄": Good to see you 😄 Also good to see you're still plugging away with Nim 😄
00:05:00*alphacentauri quit (Quit: WeeChat 4.0.5)
00:07:10FromDiscord<geekrelief> In reply to @_gumbercules "Good to see you": hehe, Actually I haven't touched Nim in several months, aside from some contract work and stuff related to gdnim. I do drop in from time to time to see what's up with internals because I chat with jmgomez everyday about the compiler's developemnt. I've been trying to figure out my art pipeline, so I can start prototyping with NimForUE.
00:09:24FromDiscord<geekrelief> Once I figure out what I can do with Blender + Unreal. I'll try to help out more with NimForUE's development. At the very least, make some docs or videos on how to use it and show off stuff on the gamedev channel.
00:12:02FromDiscord<geekrelief> lol my name collision issue is related to this old issue from years ago https://github.com/nim-lang/Nim/issues/16462
00:12:03arkanoidwould you help me how to call a __cdecl function from a statically compiled dll (ldd my.dll shows "not a dynamic executable") ? I'm on linux, but I can cross compile and run with wine I guess. The original exe runs with wine
00:13:00FromDiscord<_gumbercules> In reply to @geekrelief "Once I figure out": nice!
00:13:03FromDiscord<Elegantbeef> statically compiled dll?
00:13:24FromDiscord<Elegantbeef> You are attempting to load symbols from a dll it should be as simple as `proc doThing() {.importc: "name", dynLib: "dynLib.so".}`
00:14:09FromDiscord<Elegantbeef> I could be wrong but it being statically compiled has 0 barring on the exposed symbols in it
00:15:31arkanoidElegantbeef, sorry, what do you mean by 0 barring?
00:16:19FromDiscord<Elegantbeef> da poop\
00:16:20FromDiscord<Elegantbeef> bearing? English is da po
00:16:30FromDiscord<Elegantbeef> I mean it should have 0 influence on dynamic linking exposed symbols
00:18:03arkanoidElegantbeef, you mean the function may well call LoadDll or anything like that at runtime?
00:21:53FromDiscord<sOkam! 🫐> @pmunch Why did you choose to go with `CXCursor -> JsonArray -> NimNode -> Nim` instead of just `CXCursor -> PNode -> Nim` with `PNode.renderTree`, or even just NimNode creation directly?↵Was that a conscious choice for some reason, or you just didn't know better at the time?↵The intermediate json step feels both slow and unnecessary, but maybe I'm missing some important detail
00:37:16*krux02_ joined #nim
00:38:59*krux02 quit (Ping timeout: 246 seconds)
00:39:51FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4IgE
00:44:33FromDiscord<_gumbercules> In reply to @arkanoid "Elegantbeef, you mean the": Run dumpbin or whatever the equivalent tool is for your compiler toolchain to figure out what symbols the shared library exports
00:45:19FromDiscord<_gumbercules> If the symbol name is not listed, your C/C++ library isn't exporting it correctly.
00:47:28arkanoid_gumbercules, I'm on linux, trying to build a program that runs a specific function in a windows dll. The program would be a nim program compiled with --cpu:amd64 -d:mingw
00:48:01arkanoid_gumbercules, I'm trying to print demangled names with winedump dump -j export -C my.dll , but somehow it refuses to demangle
00:48:24FromDiscord<_gumbercules> Hmmm
00:48:41arkanoidby running wine dllexp.exe (by nirsoft) on my.dll, I can actually read demangled stuff
00:49:36FromDiscord<_gumbercules> I assume nm -g isnt going to work either then
00:50:16FromDiscord<_gumbercules> And it sounds like winedump is objdump essentially
00:51:17arkanoid_gumbercules, winedump actually has a "sym" option what works like "winedump sym 'mangledname'" and that actually works
00:51:26FromDiscord<_gumbercules> Nice!!!!
00:51:36FromDiscord<_gumbercules> I just was reading about sym hahaha
00:51:43arkanoidbut I'd need to call it one by one, and winedump dump seems to refuse to do the same itself
00:51:51FromDiscord<_gumbercules> Ooph
00:53:02FromDiscord<_gumbercules> https://stackoverflow.com/questions/13777681/demangling-in-msvc
00:53:12FromDiscord<_gumbercules> Not sure if this is relevant or helpful
00:53:26FromDiscord<_gumbercules> Im not even sure if msvc js involved here or not
00:53:32FromDiscord<_gumbercules> Is involved even
00:54:15arkanoidwell, my.dll is clearly compiled with msvc as the mangled name are in that form (they start with "?")
00:54:42FromDiscord<_gumbercules> Okay then maybe it will bear fruit
00:54:53FromDiscord<_gumbercules> 🤞
00:55:06arkanoidexample of mangled name "?SetStartProcessor@CF@@QEAAHH@Z"
00:56:08arkanoidno, neverming, winedump sym is demangling it wrong (!!!)
00:57:14arkanoidthe output of winedump sym on that is "struct CF { void **vtable; /*FIXME: class definition */ };", the demangled output according to nirsoft dllexp.exe is "public: int __cdecl CF::SetStartProcessor(int) __ptr64"
01:04:24FromDiscord<_gumbercules> Ugh
01:08:55FromDiscord<geekrelief> @darthvaderbn fixed the issue with gdnim. https://github.com/geekrelief/gdnim/commit/72e2a135479e849aeeff72e45ffb7f64e5c614da
01:51:33FromDiscord<luxurymode> In reply to @_gumbercules "It definitely sounds like": That makes more sense, thanks. I'll open a PR... assuming there's a repo for this somewhere
02:02:13FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgQ
02:02:56FromDiscord<Elegantbeef> `nim -v`?
02:03:27FromDiscord<user2m> sent a long message, see http://ix.io/4yj1
02:03:53FromDiscord<Elegantbeef> Cmon update your Nim
02:04:23FromDiscord<user2m> i'm using the nimjwt package and I'm not sure if it works with 2.0 yet
02:04:57FromDiscord<leorize> nim 2.0 sounds fancy but not that much breaking changes are there
02:04:59FromDiscord<Elegantbeef> Nim 1.6.14 exists
02:06:00FromDiscord<user2m> just switched to 1.6.14 with choosenim and still same issue
02:06:05FromDiscord<user2m> I'll try 2
02:07:00FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgR
02:07:18FromDiscord<Elegantbeef> stable
02:07:52FromDiscord<user2m> as in `choosenim stable` ?
02:08:09FromDiscord<Elegantbeef> `choosenim update stable`
02:08:09FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgS
02:08:21FromDiscord<user2m> gotcha
02:08:43FromDiscord<user2m> still same issue
02:08:50FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgT
02:09:59FromDiscord<Elegantbeef> Is that the full error message?
02:10:30FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgU
02:11:15FromDiscord<_gumbercules> In reply to @luxurymode "That makes more sense,": I think it should just be the main Nim repo but I could be mistaken.
02:12:07FromDiscord<Elegantbeef> Do you have two `Event` types in your modules?
02:12:28FromDiscord<Elegantbeef> Without a min repro it's hard to say anything
02:13:31FromDiscord<leorize> and here I thought Nim got improved error messages for these now
02:13:55FromDiscord<Elegantbeef> Hey I did it!
02:13:59FromDiscord<user2m> this is the full module
02:14:00FromDiscord<Elegantbeef> And then ring also did it
02:14:07FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgV
02:23:00FromDiscord<Elegantbeef> `EventTarget` has a `onClick` field
02:24:23arkanoidwhat would be the nim signature equivalent for " __cdecl Foo::Foo(void) __ptr64" ? I'm trying with "proc (): pointer {.cdecl.}" but it fails
02:25:11FromDiscord<Elegantbeef> `proc foo(): ptr uint64 {.cdecl.}`
02:25:38FromDiscord<leorize> what an error message
02:26:53FromDiscord<Elegantbeef> Well it's a proc that takes an `event`
02:26:53FromDiscord<Elegantbeef> So yea it's a shitty message
02:27:12FromDiscord<leorize> maybe we should start training chatgpt to figure out nim errors
02:27:31FromDiscord<Elegantbeef> Or just fix the error messages
02:27:41FromDiscord<Elegantbeef> Hmm one of those has to be easier
02:28:10arkanoidElegantbeef, thanks. Sadly it keeps going sigsegv :( https://play.nim-lang.org/#ix=4IgX
02:28:47arkanoidthe loadLib and checkedSymAddr (load symbol) parts are ok, but calling the proc goes sigsegv
02:28:56FromDiscord<Elegantbeef> Have you considered making a proper system library?
02:29:06FromDiscord<Elegantbeef> With a proper exposed name
02:29:17FromDiscord<leorize> on Windows it's likely stdcall
02:29:45FromDiscord<Elegantbeef> Yea default is stdcall, but it shouldnt matter in this case since it's a void proc no?
02:30:25FromDiscord<leorize> true
02:30:32FromDiscord<leorize> that sym name reminds me of C++ mangling
02:30:46arkanoidyes, it's C++ mangling
02:30:51arkanoidI'm not the author if that dll
02:31:04FromDiscord<leorize> then are you building with msvc?
02:31:20arkanoidno, mingw
02:31:31FromDiscord<leorize> I don't remember what's the calling convention for stuff like constructors, though
02:31:40FromDiscord<leorize> mingw and msvc have different C++ ABI
02:32:15arkanoidI'm reading the calling convention with dllexp.exe, it says cdecl
02:32:23arkanoidleorize, oh! really? damn
02:33:00FromDiscord<user2m> In reply to @Elegantbeef "`EventTarget` has a `onClick`": ahh makes sense
02:33:24FromDiscord<Elegantbeef> Don't lie to me it doesnt make sense!
02:33:34arkanoidI'm not a windows daily user so I didn't know that :( I was expecting mingw to be able to use windows dlls
02:35:50FromDiscord<Elegantbeef> Afaik it should be able to use properly authored DLLs
02:35:51FromDiscord<Elegantbeef> But it's that are not properly authored that get in the way
02:35:51FromDiscord<leorize> C++ ABI is non-standardized, unfortunately
02:36:07arkanoidmmm, here they say that clang has an msvc compatible mode https://stackoverflow.com/a/7119896
02:36:17FromDiscord<leorize> usually I'd recommend writing a bridge library that compiles to C++ and exposes C interfaces
02:36:36FromDiscord<leorize> the thing is that you don't know what the constructor symbol takes
02:36:51FromDiscord<Elegantbeef> Lol the complex chain of using a C++ dll
02:37:38arkanoidleorize, the mangled name should expose the arguments (?) dllexp.exe says quite clearly that that constructor takes no argument and has a cdecl call
02:37:54arkanoidfrom the report "public: __cdecl CFarsite::CFarsite(void) __ptr64"
02:38:38FromDiscord<leorize> i'd say that unless you can find docs saying exactly what msvc does I'd be very skeptical about it
02:40:31arkanoidleorize, thanks for the hint. I was taking ddlexp output as solid truth.
02:44:09FromDiscord<leorize> you're welcome, C++ is quite annoying to navigate
02:46:58arkanoidleorize, I read also that your suggestions about writing the C wrapper is present here too https://stackoverflow.com/a/2473242 . Damn, I was not aware about the C++ hell with msvc across versions
02:47:37arkanoidI only see two paths. Get msvc to that specific version and write a C wrapper, or possibly get clang + windows sdk work with that
02:48:01FromDiscord<leorize> something that you can try is to read up on some C++ wrapping engines
02:48:08FromDiscord<leorize> ie. the kind of stuff people use to wrap Qt
02:48:42FromDiscord<leorize> many of them just pivot to a C bridge but some appear to interface with C++ directly
02:48:42FromDiscord<leorize> but it is an annoying path
02:56:23FromDiscord<leorize> btw latest msvc abi should have backward compat for at most version 2015
03:02:58FromDiscord<_gumbercules> I went through this hell recently minus the cross compilation
03:03:45FromDiscord<_gumbercules> ended up just writing a C API because I couldn't be bothered to fuck with the vtable in the struct memory layout on the Nim side
03:04:08FromDiscord<_gumbercules> well - I didn't write the C API - I found one but regardless
03:05:58FromDiscord<leorize> if nim ever got big this will be an issue for others, too \:P
03:05:59FromDiscord<leorize> the curse of ABI
03:18:56FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ihd
03:19:07FromDiscord<Elegantbeef> Just make a C header generator, and problem solved! 😄
03:19:11FromDiscord<Elegantbeef> Sorry pascal header generator
03:19:15FromDiscord<leorize> lol
03:19:43FromDiscord<Elegantbeef> Cannot tell if that's to me or to the error message
03:19:54FromDiscord<leorize> yes \:P
03:20:10FromDiscord<leorize> also I don't think async callback works for js
03:20:12FromDiscord<Elegantbeef> import another `addEventListener` that takes a `async` proc probably
03:20:18FromDiscord<Elegantbeef> I don't know JS async
03:20:55FromDiscord<Elegantbeef> Though given I have an open PR to jellyfin, I probably should learn it
03:25:46FromDiscord<leorize> it's more that I don't think the async macro was written to handle the callback case, but I might be wrong
03:31:45FromDiscord<user2m> sent a code paste, see https://paste.rs/reuNi
03:32:40FromDiscord<user2m> kinda odd something basic like that isn't included in std/asyncjs
03:34:33FromDiscord<leorize> nim's js backend is very underdeveloped
03:37:22FromDiscord<Elegantbeef> Less the backend and more the library
04:18:20*krux02_ quit (Remote host closed the connection)
05:06:51FromDiscord<pmunch> In reply to @heysokam "<@392962235737047041> Why did you": The reason for this was to allow Futhark to look at the existing program and change how things got wrapped. Of course I ended up solving this by generating `with` statements instead, so the benefit isn't quite as big. It does however mean that the macro doesn't have to serialize the inputs to pass to the program
06:33:54*rockcavera quit (Remote host closed the connection)
06:38:56arkanoidleorize: found some details https://clang.llvm.org/docs/MSVCCompatibility.html
06:55:03*Eternado joined #nim
07:01:34*PMunch joined #nim
07:04:57*advesperacit joined #nim
07:06:06*Eternado quit (Quit: Client closed)
07:26:23*azimut_ quit (Ping timeout: 252 seconds)
08:22:13*alphacentauri joined #nim
09:19:06FromDiscord<hotdog6666> @user2m https://nim-lang.org/docs/dom.html#addEventListener%2CEventTarget%2Ccstring%2Cproc%28Event%29%2CAddEventListenerOptions
09:20:03FromDiscord<hotdog6666> In reply to @leorize "nim's js backend is": It works fine for me
09:36:00arkanoidhow can I show the compilation command line arguments that nim uses to invoke cc?
09:36:11arkanoidnimble --verbose still hides them
09:55:22FromDiscord<nnsee> `nim c --verbosity:2 whatever.nim` works for me
10:26:37arkanoidhow to pass that to nimble build?
10:39:06NimEventerNew thread by mildred: Idea : reuse libraries from other languages, see https://forum.nim-lang.org/t/10530
10:43:49FromDiscord<marioboi3112> i am really confused with how many keywords nim has, when i asked gpt it said 108, when i asked google it says 70 when i asked another ai it said its 50,
10:44:04FromDiscord<marioboi3112> does anyone know how many keywords nim has?
10:44:46FromDiscord<vindaar> https://nim-lang.github.io/Nim/manual.html#lexical-analysis-identifiers-amp-keywords
10:46:09FromDiscord<marioboi3112> In reply to @vindaar "https://nim-lang.github.io/Nim/manual.html#lexical-": alright thanks!
10:50:02PMunchAsking an AI for a question like that is like asking your crazy uncle how far away the moon is
10:50:51arkanoidhaha
10:51:31arkanoidwhat's the ratio behind which nim args wants --foo: , and which wants --foo= ?
10:52:45arkanoidfor example --cc:clang, and --clang.exe= ?
10:53:00FromDiscord<marioboi3112> In reply to @PMunch "Asking an AI for": lol understandable
10:54:42PMuncharkanoid, = and : are the same
10:54:58PMunchYou can do `--cc=clang` and `--clang.exe:<path>`
10:55:05FromDiscord<nnsee> In reply to @marioboi3112 "i am really confused": chatgpt has trouble adding 3 to 5, i wouldn't trust it with exact numbers like that
10:55:13PMunchSo the ratio is 1 I guess
10:55:34arkanoidmmm
10:56:13FromDiscord<marioboi3112> In reply to @nnsee "chatgpt has trouble adding": yeah im surprised that i asked AI for such question...
11:02:51arkanoiddo you know if I can use absolute paths for switch("clang.exe",...) ?
11:05:16arkanoidit seems to me that clang.exe and clang.linkerexe are completely ignored
11:05:53arkanoidI can type random strings in there but nimble build keeps searching for system clang
11:45:37arkanoidto me "nim cpp --cc:clang --clang.exe=this_is_ignored src/foo.nim" compiles with /usr/bin/clang++
11:46:03arkanoidI can type jibberish into --clang.exe option, as it is completely ignored
11:50:14PMunchThat's because you're compiling with cpp
11:51:30PMunchTry to set `--clang.cpp.exe`
11:52:40arkanoid... just why
12:07:19arkanoidPMunch: thanks
12:07:54PMunchIn case you want to set them system wide and have different binaries for C and C++ compilers
12:08:35PMunchBut yeah, it should probably inherit clang.exe when not set to anything
12:37:24arkanoidI'm trying to cross compile from linux to windows using clang toolchain. I'm trying to compile a trivial hello world. If I use this config.nims https://termbin.com/vnm3v with "nimble build" I pass the compilation phase, but it fails the linking phase with error "lld: error: unable to find library -ldl"
12:37:54arkanoidafaik, windows does not have libdl, and I am not asking for it, why nim wants that for an helloworld?
12:45:07FromDiscord<firq> sent a long message, see http://ix.io/4IiB
12:56:59FromDiscord<nervecenter> I'm not completely sure but there is an important rule: Stuff created with `ref` is made on the heap and GC-managed, while dynamic types like strings created without `ref` are managed by a scoped stack pointer. So they'll be destroyed when they go out of scope. If you have an unsafe pointer into that data, it's probably a dangling reference after the scope exits.
12:57:12FromDiscord<nervecenter> (edit) removed "made on the heap and"
12:57:59FromDiscord<nervecenter> Probably best to ask in #internals
13:03:34FromDiscord<firq> Ok, I didn't know that distinction, but that makes sense. Thanks.
13:05:20*PMunch quit (Quit: Leaving)
13:48:15arkanoidleorize: success! I'm calling a windows msvc c++ function from a nim program cross-compiled with x86_64-w64-mingw32-clang++ ! :)
13:50:24FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4IiR
13:53:01FromDiscord<odexine> ?
13:53:05FromDiscord<odexine> What architecture
13:53:42FromDiscord<System64 ~ Flandre Scarlet> In reply to @odexine "What architecture": My own↵But inspired from 6502 with the registers
13:53:44arkanoidbut I'm quite puzzled: who is in charge to translate/demangle c++ names? I have to call checkedSymAddr passing the msvc c++ mangled name inside the dll
13:54:14FromDiscord<odexine> In reply to @sys64 "My own But inspired": How are we supposed to answer “are there any missing op codes” then ahaha
13:54:32FromDiscord<odexine> It’s up to you? Look at other architectures and decide what to add?
13:57:17FromDiscord<jviega> You only need one instruction for turing completeness 🙂
13:58:38FromDiscord<System64 ~ Flandre Scarlet> In reply to @jviega "You only need one": Which one?
13:58:42FromDiscord<odexine> MOV
13:58:50FromDiscord<jviega> There are many options
13:58:56FromDiscord<odexine> That’s true as well
13:58:59FromDiscord<jviega> Google "one instruction machines"
13:59:01FromDiscord<odexine> The most famous one is the MOV one
13:59:04FromDiscord<jviega> It's a big thing
13:59:29FromDiscord<jviega> I thought it was ADD and Jump if Not Zero 🙂
14:00:06FromDiscord<jviega> Anyway, you don't need any more to have turing completeness if that's the bar
14:00:13FromDiscord<odexine> I think a lot of people know about movfuscator
14:00:36FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4IiX
14:01:39FromDiscord<System64 ~ Flandre Scarlet> In reply to @jviega "Google "one instruction machines"": Ah yeah and there is something↵https://github.com/xoreaxeaxeax/movfuscator
14:01:44FromDiscord<odexine> I was responding to your “which one is the only one needed for TC”
14:02:13FromDiscord<odexine> In reply to @odexine "I think a lot": Told ya @jtv
14:02:49FromDiscord<System64 ~ Flandre Scarlet> Ah yeah just saw that↵However it probably hurts performances
14:03:05FromDiscord<odexine> It does of course
14:03:15FromDiscord<odexine> That doesn’t matter in theory
14:03:32FromDiscord<jviega> Well, that's much newer, my attention in that space is about 20 years old 🙂
14:03:40FromDiscord<odexine> True
14:03:52FromDiscord<odexine> Your attention in that space is nearly as old as me
14:03:55FromDiscord<jviega> 👴 Back in my day
14:04:14FromDiscord<jviega> 🧓 Uphill, both ways!
14:04:27FromDiscord<Phil> Don't forget the hail!
14:08:37FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=4Ij1
14:16:07*rockcavera joined #nim
14:28:15FromDiscord<System64 ~ Flandre Scarlet> In reply to @nnsee "if x86_64 is to": Oh god we won't talk about x86/64 ASM NOOOOOOOOO!
14:33:38FromDiscord<leorize> arkanoid\: congrats, so what's the trick?
14:34:41arkanoidleorize, this what I had to use https://termbin.com/mjin
14:35:18arkanoidso far, I'm having success dynamically loading the functions with dynlib.loadLib + checkedSymAddr
14:35:39arkanoidI should try to move the thing to importcpp
14:36:04arkanoidalso I have to use mnvp mangled names as symbols
14:36:42arkanoidsomething like let "constructCF = cast[ConstructCF](lib.checkedSymAddr("??0CF@@QEAA@XZ"))"
14:42:45FromDiscord<nnsee> sent a long message, see http://ix.io/4Ijc
15:33:51*disso-peach quit (Quit: Leaving)
15:48:43FromDiscord<_gumbercules> In reply to @arkanoid "<@695851404832538684>, this what I": glad you got it sorted - what a headache
15:59:15arkanoid_gumbercules, yes, but I've learned a lot. Thanks for your hints
15:59:43arkanoidthere are more even better holes in my understanding right now. One related to nim is: when it mangles/demangles in ffi
16:05:04arkanoidalso I need to understand why I succeed in loading and running dll procs via dynlib, but if I try to importcpp instead the same signature I get "error: member reference base type 'void *' is not a structure or union"
16:05:58FromDiscord<leorize> if you can post the code with that error I could give you a few pointers
16:06:38FromDiscord<leorize> anything that passes through the compiler got mangled unless tricks like `importc` is used to change the mangling↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
16:12:56arkanoidleorize, thank. I've just found something curious. If I importc: "<c++ mangled name>", it works!
16:13:19arkanoidbut this is really confusing. I'm importing c++ mangled names via importc
16:13:45FromDiscord<leorize> importc is the "simple" way to name it
16:14:04FromDiscord<leorize> what it really does is that it imports a symbol by the verbatim name
16:14:22arkanoiddoes it mean that importc does nothing like remangling?
16:14:29FromDiscord<leorize> the C here just means no mangling, it doesn't even imply C calling convention
16:14:34FromDiscord<leorize> yep
16:15:28arkanoidthis works: proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importc: "?GetErrorMessage@CF@@QEAAPEADH@Z".}
16:15:56arkanoidbut I'm failing to convert that to the proper importcpp
16:16:08FromDiscord<leorize> because you won't be able to
16:16:18FromDiscord<leorize> importcpp is a pattern generator
16:16:43FromDiscord<leorize> it doesn't actually "import" a symbol
16:17:13FromDiscord<leorize> it just generates C++ calls in the source code
16:17:32FromDiscord<leorize> and requires a header defining the symbol you want to use to be included
16:17:38FromDiscord<leorize> and definitely doesn't work with `dynlib`
16:18:25arkanoidoh, wow, the two seems wildly different
16:19:24arkanoidso importc looks for a specific mangled symbol name, whatever it is (no matter if c++), and calls is with the provided calling convention
16:19:27FromDiscord<leorize> basically think of `importcpp`/`importjs` as a fancy `emit`
16:19:38FromDiscord<leorize> yep
16:21:10arkanoidthis makes sense! but why does the nim compiler lets me use importcpp even when I don't provide header pragma?
16:21:49FromDiscord<leorize> because no one blocked it \:P
16:22:10arkanoiddamn, I've spent useless hours on this!
16:22:40FromDiscord<leorize> the nicer explaination is that it's typically used to access class procs, so you would already have a `type X {.importcpp, header.}` which effectively already imported the header
16:23:13FromDiscord<leorize> and ofc, you can also just `emit` a C++ proc definition and use it directly using `importcpp`
16:24:05FromDiscord<jmgomez> In reply to @arkanoid "this makes sense! but": because you dont have to
16:24:19FromDiscord<jmgomez> the header can be included somewhere else
16:24:50arkanoidbut why does importcpp require header? I mean, if this works: proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importc: "?GetErrorMessage@CF@@QEAAPEADH@Z".} . Should I be able to do proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importcpp: "#.GetErrorMessage(@)".} ?
16:26:04FromDiscord<leorize> because it's a pattern generator
16:26:11FromDiscord<leorize> it doesn't do any symbol magic
16:27:08arkanoidok, so that it will never generate the mangled name required to find the address into the dll
16:27:19arkanoidunless the header provides it (?)
16:30:30arkanoidbtw, considering that demangling msvc c++ names is probably very possible at compile time (I'm using dllexp.exe and http://demangler.com/ right now), it could be possible to macro the thing. List exported dll procs, demangle the name, create nim signature, importc the mangled name, done
16:30:52arkanoidwell, this is if you have no types :P
16:41:45arkanoidcan I use absolute or relative function address instead of mangled name?
16:45:57*junaid_ joined #nim
16:46:29FromDiscord<Phil> sent a long message, see http://ix.io/4Ijx
16:51:11FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Ijz
17:13:22FromDiscord<System64 ~ Flandre Scarlet> In reply to @nnsee "`ADDSUBPS` > Adds odd-numbered": AAAAAAAAH my brain!
17:23:32*azimut joined #nim
17:33:26*advesperacit quit (Ping timeout: 272 seconds)
17:33:32*advesperacit_ joined #nim
17:43:01FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IjM
18:09:28arkanoidif I have a C++ function with signature "class CFSpots * __cdecl CF::GetSpots(void)", what's the return type? Is it an uncheckedArray[CFSpots], or is it a ptr CFSpots ?
18:10:45FromDiscord<mratsim> Anyone published a Rust package with a Nim backend?↵↵How did they handle calling the Nim compiler to build a .a static library and link it when people do `cargo build` or `cargo run` ?
18:19:46FromDiscord<.aingel.> In reply to @user2m "Does anyone know how": Dont know how much this will help but https://github.com/yglukhov/nimpy/issues/278
18:19:51FromDiscord<.aingel.> The author says he doesn't have a good way to fix it
18:19:59FromDiscord<.aingel.> https://stackoverflow.com/questions/19292957/how-can-i-troubleshoot-python-could-not-find-platform-independent-libraries-pr
18:20:11FromDiscord<.aingel.> This might give you some info on how to force it to work
18:25:24*krux02 joined #nim
18:30:58NimEventerNew thread by mratsim: Infiltrating Rust with Nim packages, see https://forum.nim-lang.org/t/10532
18:49:11FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ik5
19:07:05*junaid_ quit (Remote host closed the connection)
19:14:25FromDiscord<raynei486> In reply to @arkanoid "if I have a": if it's a block of memory (not just pointer to one thing) then it should be `ptr uncheckedArray[CFSpots]`
19:14:33FromDiscord<raynei486> but most of the time that's the pattern anyways
19:24:17FromDiscord<.aingel.> In reply to @user2m "Figured it out! you": Awesome!
19:24:31FromDiscord<.aingel.> Maybe you can post that in the thread on github, or if you don't plan to i'll post it
19:24:43FromDiscord<.aingel.> Cause it can help someone else trying to do the same thing
19:34:30FromDiscord<Chronos [She/Her]> I have a lib for Java codegen but... I think I need to remake it :p
19:34:37FromDiscord<Chronos [She/Her]> This was when I was new to the language
19:34:47FromDiscord<Chronos [She/Her]> Wow literally a year ago-
19:35:03FromDiscord<Chronos [She/Her]> https://github.com/Yu-Vitaqua-fer-Chronos/Codegenlib
19:35:19FromDiscord<Chronos [She/Her]> Exactly a year ago from today-
20:10:19FromDiscord<ebahie> hello, i had a question about the json module. i have been writing a discord api wrapper to learn nim and ive been having issues understanding how to parse multiple practically identical json objects from a file and nested objects and how to do this recursively
20:10:52FromDiscord<ebahie> this is what the json looks like, it can have hundreds of messages i might add this is just so i can send it here
20:11:02FromDiscord<ebahie> https://media.discordapp.net/attachments/371759389889003532/1159945930376761394/message.json?ex=6532ded4&is=652069d4&hm=9d61233d57558254ebe5ca609db44cd6d06e5572bc781d441f9306985c988bfc&
20:11:32FromDiscord<ebahie> im mainly looking for content, username and timestamp
20:16:11FromDiscord<user2m> In reply to @.aingel. "Maybe you can post": just did!
20:17:33FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/oYCTT
20:17:57FromDiscord<Elegantbeef> You also can use `std/jsonutils` to make hooks for your objects
20:18:39*derpydoo joined #nim
20:20:36*krux02 quit (Remote host closed the connection)
20:20:48FromDiscord<ebahie> sent a code paste, see https://play.nim-lang.org/#ix=4Ikw
20:23:23FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ikx
20:23:51FromDiscord<user2m> (edit) "https://play.nim-lang.org/#ix=4Ikx" => "https://play.nim-lang.org/#ix=4Iky"
20:24:15FromDiscord<nervecenter> sent a long message, see http://ix.io/4Ikz
20:24:16FromDiscord<user2m> In reply to @ebahie "but how do i": once it's in a seq you can check how many response objects there are
20:24:33FromDiscord<nervecenter> (edit) "http://ix.io/4Ikz" => "http://ix.io/4IkA"
20:24:40FromDiscord<Elegantbeef> I mean we have `std/jsonutils`
20:24:41FromDiscord<Elegantbeef> So just write a json hook
20:24:43FromDiscord<nervecenter> (edit) "http://ix.io/4IkA" => "http://ix.io/4IkB"
20:25:07FromDiscord<nervecenter> (edit) "http://ix.io/4IkB" => "http://ix.io/4IkC"
20:25:17FromDiscord<nervecenter> (edit) "http://ix.io/4IkC" => "http://ix.io/4IkD"
20:25:32FromDiscord<Elegantbeef> Nerve you're suggesting a hook but manually
20:25:45FromDiscord<Elegantbeef> Using jsonhooks are much better than manual code as it is reusable
20:25:59FromDiscord<nervecenter> And if he uses it once it's 4 lines of code that he doesn't need to reuse
20:26:03FromDiscord<nervecenter> don't add necessary steps
20:26:08FromDiscord<nervecenter> (edit) "necessary" => "unecessary"
20:26:08FromDiscord<Elegantbeef> Lol
20:26:34FromDiscord<ebahie> alright ill see what i can do
20:26:48FromDiscord<Elegantbeef> The only difference between using json hook and your way is that yours does not compose
20:26:49FromDiscord<Elegantbeef> `std/jsonutils` has a generic interface so you can deserialise any type with a implemented hook
20:27:34FromDiscord<nervecenter> He hasn't brought up any reason to need composition or reuse just yet, he's not making an enterprise application, KISS
20:27:43FromDiscord<nervecenter> Teach the basics
20:28:04FromDiscord<ebahie> is jsonutils not included in nim 2.0.0?
20:28:20FromDiscord<ebahie> https://media.discordapp.net/attachments/371759389889003532/1159950286723502241/image.png?ex=6532e2e3&is=65206de3&hm=abf811f6fad52f92da220021adf36ce4916c086d3579a9c4f0e8bd73c432860e&
20:28:23FromDiscord<Elegantbeef> It is in 2.0
20:28:33FromDiscord<Elegantbeef> `std/jsonutils`
20:28:55FromDiscord<Elegantbeef> To be fair using jsonhooks is the exact same complexity as your solution it's just more pluggable so there is not much reason not to
20:29:10FromDiscord<ebahie> In reply to @Elegantbeef "`std/jsonutils`": oooh ok
20:29:26FromDiscord<Elegantbeef> Always prefix std imports with `std/`
20:29:30FromDiscord<Elegantbeef> You can group them together doing `std/[a, b, c]`
20:30:07FromDiscord<ebahie> alrighty
20:30:33FromDiscord<Elegantbeef> But yes as nerve pointed out you do not need jsonutils, but it's highly suggested if you think any of these types will appear in other objects
20:44:48FromDiscord<.aingel.> In reply to @user2m "just did!": Awesome, thank you!
20:58:38*advesperacit_ quit (Ping timeout: 272 seconds)
20:58:42*advesperacit joined #nim
21:59:50*advesperacit quit ()
22:01:00FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4IkU
22:07:48FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4IkV
22:07:49FromDiscord<sOkam! 🫐> that's my first thought
22:08:46FromDiscord<Phil> When statements not supported within the gui block
22:09:06FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4IkW
22:09:10FromDiscord<sOkam! 🫐> oh
22:09:50FromDiscord<Phil> And if I do basically the entire body of the proc twice via when statement then I haven't really removed duplication, I've now simply moved it into the same proc
22:11:16FromDiscord<sOkam! 🫐> yeah pretty much
22:11:27FromDiscord<sOkam! 🫐> is implementing when blocks unfeasible?
22:13:32FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4IkY
22:13:48FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4IkY" => "https://play.nim-lang.org/#ix=4IkZ"
22:14:15FromDiscord<Phil> And as one might imagine `toListFormField` and `toFormField` are near identical except from where their values come from
22:15:01FromDiscord<Phil> (edit) "And as one might imagine `toListFormField` and `toFormField` are near identical except from where their values come from ... " added "and thus also where they need to modify them."
22:17:36*derpydoo quit (Quit: derpydoo)
22:21:41FromDiscord<ezquerra> sent a code paste, see https://play.nim-lang.org/#ix=4Il2
22:25:02FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Il3
22:25:08FromDiscord<Phil> on nim 2.0
22:31:09FromDiscord<ezquerra> That's odd... I'm on nim 2.0 too
22:31:35*alphacentauri quit (Quit: WeeChat 4.0.5)
22:32:19*alphacentauri joined #nim
22:32:42FromDiscord<leorize> check if your variable was shadowed
22:34:09FromDiscord<ezquerra> sent a code paste, see https://play.nim-lang.org/#ix=4Il7
22:34:28FromDiscord<Chronos [She/Her]> Sorry for interrupting but does anyone know if GitHub Actions has access to curl or?
22:34:42FromDiscord<leorize> yes, they have curl
22:35:01FromDiscord<ezquerra> It is actually generating a Hint, not a Warning but still (` Hint: 'work_size' is declared but not used [XDeclaredButNotUsed]`)
22:35:15FromDiscord<Chronos [She/Her]> Thanks!
22:36:00FromDiscord<leorize> I'm scared of that code \:P↵(@ezquerra)
22:37:39FromDiscord<leorize> if it doesn't work then maybe file an issue given that you have a minimal repro
22:37:51FromDiscord<ezquerra> Blame @mratsim 🙂
22:41:51FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ila
22:42:45FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ilb
22:54:40*alphacentauri quit (Quit: WeeChat 4.0.5)
22:56:46FromDiscord<Chronos [She/Her]> Removing the use of `nil`s in my code :)
22:57:03FromDiscord<Elegantbeef> Congrats!
23:14:41FromDiscord<inv2004> Hello, I started to check the one: https://github.com/jinyus/related_post_gen↵↵I am totally lost.↵Was trying to reading the rules and code, and it is not clear
23:15:44FromDiscord<inv2004> for example: `{p1: [a, b], p2: [b, c]}` which is correct amount of shared posts? code shows that it is `{p1: 1, p2: 0}`
23:16:04FromDiscord<inv2004> looks like it is some kind of "sliding" count, but I do not see anything like that in rules
23:16:35FromDiscord<inv2004> and it makes not sense
23:19:12FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Congrats!": Hopefully I'll make my code completely type safe eventually lol
23:19:23FromDiscord<Chronos [She/Her]> Anyway, have a good day/night y'all, logging off for now
23:25:33FromDiscord<inv2004> I would add that it just count the last post
23:42:03*alphacentauri joined #nim
23:46:09FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4Ill
23:46:29FromDiscord<Elegantbeef> `a..b` only works for sets
23:46:38FromDiscord<sOkam! 🫐> it also worked for arrays so far
23:46:56FromDiscord<leorize> you'd create an array containing a Slice
23:48:18FromDiscord<sOkam! 🫐> i guess
23:49:07FromDiscord<sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4Ilp
23:49:51FromDiscord<Elegantbeef> So does `{nkIdent, nkInfix, nkPar, nkCharLit..nkTripleStrLit}`
23:49:52FromDiscord<Elegantbeef> Atleast it should
23:50:18FromDiscord<leorize> a set is better for this job too
23:51:15FromDiscord<Elegantbeef> `O(1)` lookups go brrrrr
23:51:47FromDiscord<Elegantbeef> Plus memory efficient and faster to iterate
23:51:55FromDiscord<leorize> not to mention native support in `case of`
23:52:30FromDiscord<Elegantbeef> Now if only we could use `case` on 64bit and smaller sets