<< 07-03-2022 >>

00:00:16*tk quit (Quit: Well, this is unexpected.)
00:00:43*tk joined #nim
00:17:23*vicfred joined #nim
00:40:58*Goodbye_Vincent joined #nim
01:36:48FromDiscord<Girvo> Hi all 🙂
01:37:09FromDiscord<Elegantbeef> Hello
01:38:00FromDiscord<Girvo> Question: `esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t cfg);` that `const ` is causing me dramas, as I don't know how to define a Nim object/var as a C const?
01:38:18FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RxW
01:38:28FromDiscord<Girvo> Thats what I've got from c2nim (slightly modified)
01:39:06FromDiscord<Elegantbeef> You can use `codegendecl` to manually specify it like so https://github.com/beef331/picostdlib/blob/master/src/picostdlib/tusb.nim#L738-L739
01:39:18FromDiscord<Girvo> (edit) "https://play.nim-lang.org/#ix=3RxY" => "https://play.nim-lang.org/#ix=3RxX"
01:39:31FromDiscord<Girvo> Ah neat
01:41:24FromDiscord<Girvo> Is there a better pattern I can take when binding this to avoid this issue, out of curiosity?
01:41:42*flynn quit (Quit: Ping timeout (120 seconds))
01:41:42FromDiscord<Girvo> https://github.com/espressif/esp-idf/blob/v4.3/components/pthread/include/esp_pthread.h this is the header for reference
01:42:51*flynn joined #nim
01:45:15FromDiscord<Girvo> Oh. Putting a missing `importc, header:` pragma on the object itself and using `let` with `unsafeAddr` compiles now... though thats likely not the right way lol
01:46:22FromDiscord<Girvo> Oh I don't even need unsafeAddr. It was actually just the missing `importc` and `header` binding to the actual struct in the C header, and now its compiling nicely
01:46:43termer
01:48:26FromDiscord<Girvo> Even checked the codegen and, while it doesn't have const on it, its working now?
01:49:02FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RxZ
01:49:42FromDiscord<Girvo> Which matches the documentation. I guess the error about it not being a const was _actually_ about the symbol not matching as it was missing the importc, header?
01:49:46FromDiscord<exelotl> In reply to @Elegantbeef "Who the fuck echo's": `echo (foo, bar)` is really convenient for debug printing lol
01:54:49*toulene joined #nim
01:58:52FromDiscord<Elegantbeef> Hush hush hush
02:01:16*vicfred quit (Ping timeout: 256 seconds)
02:09:48*arkurious quit (Quit: Leaving)
02:21:23FromDiscord<huantian> Imagine debug printing with echo and not treeform’a print
02:21:31FromDiscord<huantian> (edit) "treeform’a" => "treeform’s"
02:21:33FromDiscord<Elegantbeef> Imagine debugging
02:30:21*jmdaemon quit (Ping timeout: 245 seconds)
02:36:27NimEventerNew question by itil memek cantik: Nim template&#39;s body to definitely be specifc, see https://stackoverflow.com/questions/71375884/nim-templates-body-to-definitely-be-specifc
02:44:46*toulene quit (Quit: Leaving)
02:45:10*toulene joined #nim
02:47:27FromDiscord<Girvo> In reply to @Elegantbeef "Imagine debugging": Yeah! Just write code that works first go duh..... Ez pz 😄
02:48:36FromDiscord<Rika> what is the equiv. of `declspec(dllexport)` in nim?
02:48:48FromDiscord<Rika> ive never done windows programming lmao
02:50:06FromDiscord<Rika> {.dynlib.} i assume
02:57:04termer
02:58:06FromDiscord<Girvo> Question: why would `warning: "_GNU_SOURCE" redefined` be trigged (nimbase.h and stdlib_system.nim.c both seem to define it lol)
03:02:00FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3Ryd
03:04:28*jmdaemon joined #nim
03:13:44FromDiscord<Girvo> Can one view the error value of `createThread` somehow?
03:14:43*krux02 quit (Remote host closed the connection)
03:18:46FromDiscord<Girvo> Better question: is there any good docs I should look at for Nim's usage of `pthreads` -- as it seems Nim threads aren't quite supported for FreeRTOS/ESP-IDF right now
03:19:51*toulene quit (Quit: Leaving)
03:20:13FromDiscord<Elegantbeef> Should be the same as C
03:20:45FromDiscord<Girvo> Alrighty
03:21:39FromDiscord<Girvo> Damn. I really like Nim's thread support lol. Oh well! Might stick with FreeRTOS tasks after all then. Any reason I can't use Channels with a pthread/Task?
03:22:04FromDiscord<Elegantbeef> Locks should still work afaik
03:22:29FromDiscord<Elegantbeef> So yea i think channels should be safe
03:26:21*toulene joined #nim
03:35:02FromDiscord<Girvo> Awesp,e
03:35:05FromDiscord<Girvo> (edit) "Awesp,e" => "Awesome"
03:35:15FromDiscord<Girvo> I'll have a play. Beats having to use the straight C stuff at least
03:35:43FromDiscord<Girvo> I do wonder what it would take to get Nim's thread module working on ESP32 mind you... might have to do some digging
03:37:16*symgryph joined #nim
03:40:52symgryphquick question on VS code for mac with the nim plugin (there seem to be 2 of them, nim 0.6.6 and 0.1.2.5 from nimsaem Neither of them seems to 'check on type' but only 'check on save' any way to have autocheck w/o having to save code?
03:41:14symgryphaka instatype?
03:41:30FromDiscord<Elegantbeef> There is not
03:41:38FromDiscord<Elegantbeef> just enable autosave every Xms
03:41:58symgryphI see. the videos I was watching made it look like it was instatype'
03:42:20FromDiscord<Elegantbeef> Yea it's instant with autosave 😛
03:43:19symgryphah. Which nim plugin is the 'best' the 0.6 or the other nimsaem?
03:43:31symgryphsince the 'nim' one seems to have more people
03:43:31FromDiscord<Elegantbeef> saem's
03:45:14symgryphThank you elegant beef. I turned on 'automatic' save with a 1000MS delay seems 'instant' enough now.
03:46:01symgryphAlso shouldn't the message be updated to nim is 1.6.4?
03:46:06symgryphsince 1.6.0 is old now.
03:46:16FromDiscord<Elegantbeef> message?
03:46:26symgryphThe topic for irc://irc.libera.chat:6697/#nim is: 👑 Nim programming language - http://nim-lang.org/ | https://github.com/nim-lang/Nim/wiki/IRC-guidelines | Latest version: 1.6.0 - https://nim-lang.org/install.html | Forum: http://forum.nim-lang.org/ | IRC logs: http://irclogs.nim-lang.org/ | Bridged to Discord/Gitter/Matrix: https://discord.com/invite/nim | See also irc://irc.libera.chat:6697/#nim-offtopic irc://irc.libera.chat:6
03:46:26symgryph697/#nim-nologs | http://git.io/gHZGCg (10:37)
03:46:26symgryphTopic for #nim set by [email protected] at 15:29:54 on 11/07/21 (10:37)
03:46:32symgryphthe initial sign on message
03:46:41symgryphwhen you first login to the channel
03:47:42FromDiscord<Elegantbeef> Ah irc
03:47:49symgryphYes.
03:48:00symgryphShould I be using discord, the thing said 'irc is our main'
03:48:13FromDiscord<Elegantbeef> I use matrix, it's purely up to you
03:48:27FromDiscord<Elegantbeef> If you prefer IRC use it, otherwise use what you prefer
03:48:34symgryphJust got liberachat working with cloaking and happy NIC registering.
03:48:36FromDiscord<Elegantbeef> They're all linked together so it doesnt really matter
03:49:05FromDiscord<Rika> use whichever
03:49:19FromDiscord<Girvo> Interesting, `createThread` is failing with `ResourceExhaustedError` -- though createThread really only checks if `!= 0` it seems anyway, so it might be a different error?
03:49:54symgryphHas anyone used the very nice "nim for beginners' video series on youtube? I tried NIM in action, but its a bit over my head (our first app was a multi-threaded chat app!)
03:50:09FromDiscord<Rika> probably
03:50:12FromDiscord<Rika> not me
03:50:13symgryphThe Nim for beginners seems more geared to my level (a former perl programmer)
03:50:38symgryphIs there anything besides 'nim in action' ?
03:50:48FromDiscord<Elegantbeef> The nim programming book
03:51:00symgryphI looked high and low on oreilly safari and could only find that
03:51:11symgryphURL?
03:51:48FromDiscord<Rika> theres also https://ssalewski.de/nimprogramming.html maybe
03:51:53FromDiscord<Elegantbeef> https://ssalewski.de/nimprogramming.html
03:52:03FromDiscord<Rika> haha slow
03:52:25FromDiscord<Elegantbeef> Indeed
03:56:53symgryphThank you. Its very nice. any epub versions available?
03:57:27symgryphI did convert it, but was wondering if its natively available in epub version? I use an ebook reader to do most of my programming.
03:58:28FromDiscord<Rika> not that i know of, no
04:00:23symgryphWould anyone else have use for a 'epub' version? Should I send to the author?
04:01:10FromDiscord<Rika> i dont know
04:06:02*supakeen quit (Quit: WeeChat 3.4)
04:06:32*supakeen joined #nim
04:29:12*toulene quit (Remote host closed the connection)
04:29:31*toulene joined #nim
04:38:42*toulene quit (Remote host closed the connection)
04:39:01*toulene joined #nim
04:43:37FromDiscord<abdu> sent a code paste, see https://play.nim-lang.org/#ix=3Ryl
04:45:07FromDiscord<Elegantbeef> You probably need to use a macro
04:45:38FromDiscord<Elegantbeef> Or not
04:46:20FromDiscord<huantian> there was this thread here <https://forum.nim-lang.org/t/8970>
04:48:02FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Ryn
04:48:03FromDiscord<Elegantbeef> There we go
04:48:15FromDiscord<huantian> your indents are a tad wonky beef 😛
04:48:31FromDiscord<Elegantbeef> What can i say they were wonky from the first paste
04:57:48*slowButPresent quit (Quit: leaving)
05:20:44*rockcavera quit (Remote host closed the connection)
05:20:49*symgryph quit (Quit: Leaving.)
05:33:12*toulene quit (Remote host closed the connection)
05:33:31*toulene joined #nim
05:38:13*user30959 joined #nim
05:39:00*toulene quit (Ping timeout: 250 seconds)
05:50:53*user30959 quit (Quit: Leaving)
05:59:03FromDiscord<Girvo> Where would one find the {.thread.} pragma's definition in the source?
05:59:33FromDiscord<Elegantbeef> It's compiler magic and equivlent with `gcsafe`
05:59:57FromDiscord<Girvo> Okay neat
06:04:47FromDiscord<Girvo> So it will work no worries with pthread_create and/or xTaskCreate, and just give me the GC-variable-access checks?
06:05:11FromDiscord<Elegantbeef> what is the proc def for those?
06:06:22FromDiscord<Elegantbeef> Ah it uses `noconv`
06:10:01FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3RyI
06:58:52FromDiscord<Girvo> Interestingly, `{.thread.}` actually causes a fatal crash, but `{.gcsafe.}` works fine. I'm guessing `{.thread.}` does slightly more under the hood?
06:59:44FromDiscord<Elegantbeef> You still have noconv on both right?
06:59:48FromDiscord<Girvo> Yep
07:00:06FromDiscord<Elegantbeef> Odd that thread crashes, i dont think it does anything but ensure it's thread safe
07:01:18FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#threads-thread-pragma like there is nothing about it changing the code, and i dont recall the compilers internals doing it
07:01:53FromDiscord<Girvo> Yeah. I think its because the FreeRTOS work that was done for Nim from Nesper isn't entirely complete -- createThread for example always fails, among other things, despite `pthread` support working no worries (including from `import posix`). I might take a look into it and see if I can't fix it myself
07:02:06FromDiscord<Girvo> But I'm not entirely sure.
07:02:32FromDiscord<Elegantbeef> Hmm can you show the C gen'd code with thread vs gcsafe?
07:02:36FromDiscord<Elegantbeef> I'm curious what's actually different
07:02:37FromDiscord<Girvo> Yeah I can!
07:03:20FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RyQ
07:04:37FromDiscord<Elegantbeef> I'm guessing the thread pragma somehow is changing the code, even though it shouldnt
07:05:23FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RyR
07:05:48FromDiscord<Elegantbeef> Is the call site for `XTaskCreate` the same?
07:05:53FromDiscord<Girvo> I'll have a look, one tick
07:08:12FromDiscord<Girvo> It honestly looks like it is lol. I'll have to dig a bit deeper as this is all spread out over some modules. I'll write a much simpler test case to see if I can replicate the issue
07:08:45FromDiscord<Elegantbeef> Remember you can do `-d:danger` to make the generated C more compact
07:08:50FromDiscord<Girvo> Oh!
07:08:55FromDiscord<Girvo> Cheers, I'll do that
07:09:13FromDiscord<Elegantbeef> It removes all the debug information and many checks, but it also makes it easier to search through imo
07:10:08FromDiscord<Girvo> Yeah this is so much easier to readl ol
07:10:46FromDiscord<Elegantbeef> If the function def isnt different and the call site isnt different this is an absurdly weird bug
07:10:58FromDiscord<Girvo> Hah so, it absolutely _is_ identical in terms of `main.nim` output
07:11:28FromDiscord<Elegantbeef> Are you certain the gcsafe always behaves properly?
07:12:08FromDiscord<Girvo> _and_ the tasks.nim which is where the xTaskCreate call lives is also identical. I'm definitely gonna have to look deeper, I think your instincts are right and there is something else at play here
07:12:34FromDiscord<Girvo> Though I _did_ make the test case as simple as a single task proc that does not much, other than have `{.thread, noconv.}` on it
07:12:35FromDiscord<Elegantbeef> My present thought is there is some UB being expressed
07:12:39FromDiscord<Girvo> And yeah I think so too
07:13:47FromDiscord<Girvo> I'll have a dig around. See if I can't get the simplest test case possible for this, and examine what the C is doing. Will let you know, might make an issue if there is something not-obvious happening
07:14:17FromDiscord<Elegantbeef> Ok
07:14:51FromDiscord<Elegantbeef> I had something similar before with gcsafe but between gcsafe and non gcsafe
07:15:12FromDiscord<Elegantbeef> But different API so i could happily just remove the `gcsafe` annotation and carry on
07:15:44FromDiscord<Elegantbeef> It also only effected WASM so it was super odd
07:16:37FromDiscord<Girvo> Yeah. Technically that is sort of what is happening here, the `app_main:` template from Nesper won't have gcsafe on it (nor {.thread.} obviously) is where the `newTask` proc is called which itself calls `xTaskCreate` -- but I'll have a look as mostly all app_main does is make sure some certain things are in place so ESP-IDF can pick up our main function correctly
07:18:31FromDiscord<Girvo> But yeah theres nothing immediately obvious as to why it would work here with `{.gcsafe.}` and not `{.thread.}` even in terms of the C output. Fascinating
07:20:17FromDiscord<Girvo> Only thing I can think of is something to do with how stacks and such are setup with Nim and `{.thread.}` compared to how `xTaskCreate` expects things to work. I might change it out from the Task interface to actual `pthread_create` and such, and see whether that has the same problem, too
07:23:36FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RyU
07:23:45FromDiscord<Girvo> (edit) "https://play.nim-lang.org/#ix=3RyU" => "https://play.nim-lang.org/#ix=3RyV"
07:26:42*jjido joined #nim
07:36:22*jmdaemon quit (Ping timeout: 272 seconds)
07:36:37FromDiscord<Girvo> Ah hah! CMake had tripped up somehow, and it _always_ errors even with gcsafe _or_ thread
07:36:56FromDiscord<Elegantbeef> Ah
07:37:04FromDiscord<Elegantbeef> That makes 130% more sense
07:37:09FromDiscord<Girvo> Amen 😂
07:37:17FromDiscord<Girvo> I was losing my mind for a moment here
07:37:50*jmdaemon joined #nim
07:38:40FromDiscord<Girvo> Oh my gosh
07:38:48FromDiscord<Elegantbeef> Pmunch you about?
07:40:28FromDiscord<Girvo> It's noconv, not gcsafe/thread, I think. Let me look a bit deeper. I have a feeling the Nesper `xTaskCreate` binding is missing it, it only expects `{.cdecl.}` so I can't put `{.noconv.}` on the wrapper proc that is actually _passed_ to `xTaskCreate`
07:41:02FromDiscord<Elegantbeef> what does the C def of XTaskCreate look for?
07:41:07FromDiscord<Girvo> One moment
07:43:24FromDiscord<b4mbus> where do I learn more about command syntax?
07:44:06FromDiscord<Girvo> `TaskFunction_t ` which is: ... annoying to find, one moment lol
07:44:34FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax
07:44:37FromDiscord<b4mbus> (edit) "syntax?" => "syntax?↵I checked tutorial1 tutorial2 and tutorial3 as well as the language manual and the only thing there is is an EBNF with a comment `command syntax`"
07:44:47FromDiscord<Girvo> Though as pvTaskCode:↵> Pointer to the task entry function (just the name of the function that implements the task, see the example below).
07:44:54FromDiscord<Girvo> https://www.freertos.org/a00125.html
07:45:34FromDiscord<b4mbus> In reply to @Elegantbeef "https://nim-lang.org/docs/manual.html#procedures-co": I see, thanks
07:45:36FromDiscord<Elegantbeef> I'd imagine it should be a `cdecl` proc in Nim but without seeing the C typedef I dont know
07:47:00FromDiscord<Girvo> It definitely does need to be cdecl yeah. I adjusted the Nim wrapper from Nesper to define it as `{.cdecl, noconv.}` and now passing gcsafe/thread procs to the wrapper function work
07:47:19FromDiscord<Elegantbeef> `cdecl, noconv` is 100% silly
07:47:22FromDiscord<Elegantbeef> `noConv` was for the pthread api
07:47:38FromDiscord<Elegantbeef> The calling convention used is noConv for the posix api
07:48:02FromDiscord<Elegantbeef> noConv and cdecl are both calling conventions, so they dont make sense to be used in unison
07:48:08FromDiscord<Girvo> That makes sense to me 🙂
07:49:09FromDiscord<Elegantbeef> Guess i'll abuse pmunch later when he's actually on
07:49:15FromDiscord<Girvo> The pthread API in this instance is actually just a wrapper over the xTaskCreate stuff anyway, interestingly enough
07:49:31FromDiscord<Girvo> I'm going to have a play with all of that next to see if there are any sharp edges
07:49:46FromDiscord<Elegantbeef> Ah so you should infact make it take a `{.thread, cDecl.}` procedure
07:50:11FromDiscord<Girvo> :catnod:
07:51:34FromDiscord<Elegantbeef> "This has been an episode of 'Beef states the obvious to someone'"
07:52:39FromDiscord<Girvo> Haha nah its super helpful anyway! Theres so many layers here keeping them all straight in my head is a real task
07:52:47FromDiscord<Girvo> Or should I say, xTaskCreate
08:07:09FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3RyZ
08:07:41FromDiscord<Girvo> And if you do, you'll have a bad time as there is no actual pointer passed now
08:08:18FromDiscord<Girvo> Hence why I was trying to do a wrapper in the first place, but it had the same error we've been talking about when used with `{.thread, cdecl.}`
08:08:29FromDiscord<Girvo> (edit) "Hence why I was trying to do a wrapper in the first place, but it had the same error we've been talking about when used with `{.thread, cdecl.}` ... " added "on the wrapper"
08:10:02FromDiscord<Elegantbeef> What was the wrapper?
08:10:33FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3Rz0
08:11:32FromDiscord<Elegantbeef> Hmmm
08:12:04FromDiscord<Elegantbeef> And how do you create the task + pass the object?
08:13:03FromDiscord<Girvo> So this is the "InstrFetchProhibited" code: https://pastebin.com/2QJsZean
08:13:50FromDiscord<Girvo> `var tModem = newTask(sendAT, "sendAT", (16384 3).SzBytes)` is how its being used
08:16:01FromDiscord<whisperdev> Wow is Nitter the most well known Nim app in the wild?
08:16:08FromDiscord<Elegantbeef> Probably
08:16:18FromDiscord<Elegantbeef> Hmm if result isnt NVRO'd you might have an issue
08:16:43FromDiscord<Girvo> Yeah I had a feeling I was doing something wrong in that newTask proc
08:16:55FromDiscord<Elegantbeef> `echo cast[int](result.addr)` `echo cast[int](tModem.addr)` where they belong
08:17:09FromDiscord<Elegantbeef> That's if it can print before it crashes
08:17:16FromDiscord<Girvo> Alright I'll give it a try
08:18:01FromDiscord<Elegantbeef> You might need to make a api that takes a `var Task`
08:18:37FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Rz1
08:19:07FromDiscord<Elegantbeef> I'm just guessing that the issue is that `addr result` is the issue, i'm probably wrong
08:19:17FromDiscord<Girvo> So thats honestly my guess too
08:19:23FromDiscord<Girvo> Wanna know something hilarious
08:19:34FromDiscord<Elegantbeef> Always
08:19:47FromDiscord<Girvo> Adding those echos? It now works. Removing them? Back to the InstrFetchProhibited 😉
08:20:00FromDiscord<Girvo> So I reckon that addr result is on the right track
08:20:07FromDiscord<Elegantbeef> Echo is thread safe so it's locking the code someehwere long enough
08:20:10FromDiscord<Girvo> Yeah
08:20:18FromDiscord<Elegantbeef> Were the addresses the same?
08:20:28FromDiscord<Girvo> One sec, I'll check again
08:21:44FromDiscord<Girvo> Yep they are the same
08:23:11FromDiscord<Elegantbeef> Does it work if you write the code manually outside a proc?
08:24:41FromDiscord<Girvo> If you mean xTaskCreate itself? Yeah it does
08:25:32FromDiscord<Elegantbeef> Wait a minute
08:25:32FromDiscord<Girvo> I'll strip it all back to the simplest things possible and see if I can replicate it. I'm certain it's something to do with how I'm defining this Task object and how it interacts with xTaskCreate memory-wise
08:25:41FromDiscord<Elegantbeef> What's the `ret` value?
08:26:00FromDiscord<Girvo> `ret: BaseType_t` -- the returned value from xTaskCreate itself
08:26:03FromDiscord<Elegantbeef> if it doesnt create teh task and you go to destroy the object it'll error
08:26:12FromDiscord<Elegantbeef> No i mean is it successful
08:26:17FromDiscord<Girvo> Oh!
08:26:20FromDiscord<Girvo> Actually good point
08:26:23FromDiscord<Girvo> one second please
08:26:36FromDiscord<Elegantbeef> Fuck no i want the answer now!!!! 😛
08:27:39FromDiscord<Girvo> Oh man what the fuck, lol. Its working now. This has to be in UB-land, right?
08:30:43FromDiscord<Girvo> sent a code paste, see https://paste.rs/D1R
08:32:57FromDiscord<Girvo> And it still works
08:32:58FromDiscord<Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3Rz2
08:33:52FromDiscord<Girvo> Add it into both? And it fails! And fails at `var tModem = newTask(sendAT, "sendAT", (16384 3).SzBytes)`
08:35:17FromDiscord<Girvo> Something to do with global variables, closures/procs and how that works with cdecl perhaps? I might just ditch this whole Task wrapper and just document how to use xTaskCreate properly instead, because this is starting to hurt my head lol. And using it straight, seems to work no worries even with both lock accesses
08:38:03*toulene joined #nim
08:41:51*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
08:42:02FromDiscord<Girvo> Ditching the whole wrapper stuff, sticking to raw `xTaskCreate`, the lock accesses work fine
08:44:33*PMunch joined #nim
09:03:29*user30959 joined #nim
09:04:27FromDiscord<Elegantbeef> Hmm pmunch is alive on offtopic maybe here aswell
09:04:53*user30959 quit (Remote host closed the connection)
09:05:07PMunchGood morning
09:05:37*toulene quit (Ping timeout: 240 seconds)
09:05:40FromDiscord<Elegantbeef> How to futhark files in `/usr/include/`?
09:05:49PMunchJust like normal`
09:06:07FromDiscord<Elegantbeef> Ah so then i'm an idiot
09:06:13PMunch`sysPath "/usr/include"; "mylib.h"`
09:06:37FromDiscord<Elegantbeef> Oh i see
09:06:39PMunchI guess you tried to use `path "/usr/include"` and it blew up from recursion depth?
09:07:10FromDiscord<Elegantbeef> Nah i did `path "/usr/include/mylib/file"`
09:07:21PMunchAh, yeah that's not how it works
09:07:26FromDiscord<Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3Rza
09:07:44PMunch`path` is used to specify paths to automatically import required headers from
09:07:52FromDiscord<Waldecir Santos> (edit) "https://play.nim-lang.org/#ix=3Rza" => "https://play.nim-lang.org/#ix=3Rzb"
09:08:50FromDiscord<Rika> In reply to @Waldecir Santos "I need to have": It doesn’t look like you need either var written in that proc signature?
09:09:01FromDiscord<Rika> Remove the one on the result type
09:09:27FromDiscord<Waldecir Santos> I do need it because the idea is to chain other functions calls, this is just an example.
09:09:45FromDiscord<Waldecir Santos> The object will be "resolved' as soon I try to iterate or print it.
09:11:01PMunchhttps://play.nim-lang.org/#ix=3Rzc
09:11:22PMunchYou don't use var on the return type, the mutability of a symbol is determined by how it's stored by the caller
09:11:23FromDiscord<Elegantbeef> Aw yay my lack of understanding how C imports should be
09:11:41FromDiscord<Elegantbeef> `#include <spa/utils/string.h>` in C, should be done how in futhark?
09:11:46PMunch@Elegantbeef, well this is a bit of an implementation detail in Futhark
09:12:03FromDiscord<Elegantbeef> I figured it was done the same
09:12:22FromDiscord<Waldecir Santos> In reply to @PMunch "You don't use var": It fails if I chain the calls I need, I'll try to create a more complete version of the example to be more clear
09:12:27PMunch`sysPath "<path to clang includes>; path "/usr/include/spa"; "utils/string.h"` is how I'd do it
09:12:58PMunchThat way anything in /usr/include/spa which spa/utils/string.h might need is included automatically
09:13:13PMunchOr rather, will be included automatically if it uses them
09:13:49PMunchOr you could just do `sysPath "<path to clang includes>; sysPath "/usr/include"; "spa/utils/string.h"` if you don't want to import anything but the definitions in string.h itself
09:14:11FromDiscord<Rika> In reply to @Waldecir Santos "It fails if I": Remove var on both the input and output types then
09:14:16FromDiscord<Rika> Neither seems to be required
09:14:23PMunchAny objects outside of the string.h module will simply be a `distinct object` so that pointers to it still works but you won't be able to see any of their fields.
09:14:28FromDiscord<Rika> Chaining calls usually have neither of them as var
09:14:31FromDiscord<Elegantbeef> Yea i've tried a bunch of these variants of this
09:14:37FromDiscord<Elegantbeef> It doesnt work
09:15:24PMunch@Waldecir_Santos, you're probably running into the "an inline call is not mutable" issue, try reading up on `dup`.
09:15:30PMunch@Elegantbeef, doesn't work?
09:15:37PMunchCould you be a bit more specific? :P
09:15:56FromDiscord<Elegantbeef> Nope opir just cries
09:16:02PMunchAbout what
09:16:20FromDiscord<Elegantbeef> Sorry it's unable to parse the output of opir
09:16:41PMunchBy the way @Elegantbeef I tried Elden Ring with first my old Ouya controller, then an Xbox One controller. And the difference between those and mouse+keyboard is night and day :P
09:16:56PMunchCould you just give me the full error message? :P
09:17:20FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Rzf
09:17:42FromDiscord<Elegantbeef> Oh fuck i didnt see the above messages
09:17:44PMunchAha, so that's a libclang error
09:17:51FromDiscord<Elegantbeef> My bad, i'll go in my hidey hole
09:18:01PMunchIt basically means it wasn't able to parse the files
09:18:15FromDiscord<Waldecir Santos> In reply to @PMunch "@Waldecir_Santos, you're probably running": yeap, thank you
09:18:18FromDiscord<Elegantbeef> No no no, dont worry i was missing the actual errors above
09:19:22PMunchAh right
09:19:55FromDiscord<Elegantbeef> My terminal was docked just enough that i seen the parsing of opir output but not the fatal error above
09:20:06FromDiscord<Elegantbeef> Just a simple include path isssue
09:20:19FromDiscord<Elegantbeef> 'simple' rather
09:21:24FromDiscord<Elegantbeef> Unknown type names, now that I can read 😛
09:22:39FromDiscord<untoreh> can I `stat` a file at compile time?
09:23:12FromDiscord<Elegantbeef> You can use `gorge` to run a command at CT
09:23:45PMunch@Elegantbeef, so everything works fine now?
09:24:05FromDiscord<Elegantbeef> Well i have an issue with stdint.h but i now know where the errors are
09:25:36FromDiscord<untoreh> gorge doesn't help with debugging since at runtime I would use stat not exec
09:26:57PMunch@Elegantbeef, issue with stdint.h?
09:27:51FromDiscord<Elegantbeef> About 10 of `Error: unknown type name 'uint32_t'`
09:29:44PMunchFrom libclang? Or from Nim?
09:30:01FromDiscord<Elegantbeef> libclang i believe
09:31:12PMunchIt sounds like you haven't set up your clang library imports correctly
09:31:37PMunchDo you have something like `sysPath "/usr/lib/clang/13.0.1/include"` in your Futhark definition?
09:31:47FromDiscord<Elegantbeef> i have the syspath setup just as you did and i checked and ensured it exists
09:31:58PMunchJust as I did?
09:32:07FromDiscord<Elegantbeef> In the futhark example
09:32:19PMunchCould you share the futhark definition you're using?
09:32:47FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3Rzj
09:34:02PMunchAnd `find "/usr/lib/clang/12.0.1/include/" -name "stdint.h"` returns a file?
09:34:15FromDiscord<Elegantbeef> Yes
09:34:23PMunchYou might need to add "/usr/lib/clang/12.0.1/include-fixed/" as well
09:34:26FromDiscord<Elegantbeef> Like i said i did ensure that path existed
09:34:34FromDiscord<Elegantbeef> That folder doesnt exist
09:34:46PMunchOkay, never mind that then :P
09:34:48FromDiscord<Elegantbeef> There is only `include` and `lib`
09:36:23PMunchHmm, it worked for me (albeit with clang 13.0.1)
09:36:36FromDiscord<Elegantbeef> I can try 13
09:36:50FromDiscord<Elegantbeef> Works
09:36:59FromDiscord<System64 ~ Flandre Scarlet> sent a long message, see http://ix.io/3Rzm
09:38:55PMunch@Elegantbeef, by the way, if you do this it pulls it about 6x the amount of definitions: http://ix.io/3Rzn/nim because it can now automatically import some more required stuff
09:39:12FromDiscord<Waldecir Santos> In reply to @PMunch "@Waldecir_Santos, you're probably running": Dup is "working" but the old object is affect too, seems like they have the same reference https://play.nim-lang.org/#ix=3Rzo
09:39:18*Zectbumo quit (Read error: Connection reset by peer)
09:39:33*Zectbumo joined #nim
09:40:10PMunch@System64_~_Flandre_Scarlet, Futhark will never create a ref type. So I believe the `Reference` part there is just because that is the documentation reference :P
09:40:41FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, Futhark will never": Ah alright, but why I can't set the values then?
09:40:48FromDiscord<Rika> Deep copy is needed because it’s a ref. I assume it only does a shallow copy
09:41:02PMunchUnions are just like structs, but instead of the fields being one after each other in memory, and you're able to set all the fields at the same time, a union has all the fields in the same memory location, and you're only able to set one of them.
09:41:28FromDiscord<System64 ~ Flandre Scarlet> it doesn't even purpose me to set the index https://media.discordapp.net/attachments/371759389889003532/950327313587904542/unknown.png
09:41:33FromDiscord<Waldecir Santos> In reply to @Rika "Deep copy is needed": Correct if I convert back to "non-ref" it works, I'll play around with it, lets see
09:42:45FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/950327634305380402/unknown.png
09:42:56PMunch@System64_~_Flandre_Scarlet, just try it, might be that nimsuggest is broken
09:43:20PMunchHmm
09:43:55PMunchYou can try go-to definition for Tlntile and see if that gives you anything
09:44:05FromDiscord<System64 ~ Flandre Scarlet> wdym?
09:44:25PMunchBasically tell your editor to open where it is defined
09:44:31PMunchThis should show you the Futhark cache file
09:44:54FromDiscord<System64 ~ Flandre Scarlet> I copied and renamed the futhark file
09:45:25FromDiscord<System64 ~ Flandre Scarlet> ah yeah it opens where it's defined
09:45:57FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3Rzp
09:46:16PMunchAnd now go to the definition of Tlntile_973078868
09:46:27FromDiscord<System64 ~ Flandre Scarlet> ``Tlntile_973078868 = ptr uniontile_973078865``
09:46:37PMunchAnd now to uniontile_973078865
09:47:05FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3Rzq
09:47:28PMunchAnd now to uniontile_973078864 (this should be the last jump)
09:47:28FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://paste.rs/K5D
09:47:42PMunchHmm, weird
09:47:44FromDiscord<System64 ~ Flandre Scarlet> (edit)
09:48:15PMunchI think I need to try this myself
09:48:15FromDiscord<System64 ~ Flandre Scarlet> both values are packed I guess?
09:48:25PMunchYeah but it should work fine
09:51:03FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Yeah but it should": I dunno why it behaves like this
09:51:47PMunchHmm
09:51:53FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3Rzs
09:52:20PMunchHmm, it seems to be a Futhark bug
09:52:56*toulene joined #nim
09:53:12PMunchWhat you can do is copy that c2nim definition but name it `uniontile` before you run Futhark
09:53:19PMunchOr before you import the Futhark file
09:53:40PMunchAll those `when defined()` statements should mean that it now uses your definition instead of the one generated by Futhark
09:53:40FromDiscord<System64 ~ Flandre Scarlet> it will work?
09:53:48PMunchYeah that should work fine
09:54:12PMunchYou can see from what you pasted here: https://play.nim-lang.org/#ix=3Rzq
09:54:26PMunchThat it will grab that definition for uniontile if it exists already
09:55:36FromDiscord<System64 ~ Flandre Scarlet> so I have to replace that?
09:55:45PMunchNo you don't have to replace anything
09:56:20FromDiscord<System64 ~ Flandre Scarlet> so what should I do?
09:56:35PMunchSimply take the definition you have from c2nim (and rename the uint16T stuff to normal Nim uint16) and paste that in before you import the file generated by Futhark (or run Futhark)
09:57:09PMunchOh, and in that c2nim snippet, rename Tile to uniontile.
09:58:06FromDiscord<System64 ~ Flandre Scarlet> Like that I guess? https://media.discordapp.net/attachments/371759389889003532/950331498257592330/unknown.png
09:58:15FromDiscord<System64 ~ Flandre Scarlet> This is the Futhark file
09:58:25PMunchNope
09:58:31PMunchDon't edit the Futhark file at all
09:58:35PMunchNever edit the Futhark file
09:58:51FromDiscord<System64 ~ Flandre Scarlet> alright
09:59:00PMunchTake line 2-9 in that snippet, and copy it into your project, right before you import that file.
09:59:30PMunchOh wait, you should probably `include` that file now that I think about it
09:59:30FromDiscord<Elegantbeef> "Dont edit the futhark file at all" Jeez pmunch, you're not my mom you cant tell me what to do
09:59:36PMunchI think that's what Futhark does
09:59:59PMunch@Elegantbeef, haha, I mean edit it to your hearts desire, but don't come crying to me when stuff stops working :P
10:00:09PMunchOr when Futhark overrides the file because it is only a cache file
10:00:36FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Oh wait, you should": including that file?
10:01:05PMunchChange `import futhark_<numbers>.nim` to `include futhark_<numbers>.nim`
10:01:27FromDiscord<System64 ~ Flandre Scarlet> what's the difference?
10:01:30PMunchIf you have copied that file into your project, if you're still running Futhark with importc you don't have to worry about it
10:01:43PMunch`include` essentially just reads the file and copies it into the current file
10:01:54PMunch`import` imports it as it's own separate module
10:02:01FromDiscord<System64 ~ Flandre Scarlet> ah yeah just like C then
10:02:50PMunchThe Futhark `importc` macro returns the AST which it saves to the `futhark_<numbers>.nim` file, or an `include futhark_<numbers>.nim` statement
10:03:24PMunchAnd I think that you might need to `include` it for those `when declared` statements to work. But maybe not now that I think about it
10:04:53FromDiscord<System64 ~ Flandre Scarlet> okay I put this snippet into a separate file and imported the file before futhark
10:05:12FromDiscord<System64 ~ Flandre Scarlet> Like that (where TilengineBinding is the Futhark file) https://media.discordapp.net/attachments/371759389889003532/950333285261791232/unknown.png
10:05:25PMunchHmm, that might work
10:05:32PMunchHaven't tested that
10:07:08FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/950333772040126514/unknown.png
10:08:05PMunchAh, it is now in a field called anoTilengine132
10:08:14PMunchAs you can see in your definition
10:08:30FromDiscord<System64 ~ Flandre Scarlet> yeah
10:08:55PMunchSo you need to do tile.aneTilengine132.index
10:11:04FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/950334760767610930/unknown.png
10:13:54FromDiscord<System64 ~ Flandre Scarlet> And I tried to cast, doesn't work
10:14:54PMunchThat's because you do `var tile: Types.uniontile`
10:15:04PMunchThat should be `var tile: Tlntile`
10:16:05FromDiscord<System64 ~ Flandre Scarlet> I have now only access to value
10:16:40PMunchNot to `anoTilengine132?
10:16:54FromDiscord<System64 ~ Flandre Scarlet> Not even
10:17:24PMunchI guess you need to include Types and TilengineBinding
10:17:29PMunchInstead of importing them
10:18:25FromDiscord<System64 ~ Flandre Scarlet> changes nothing, it gets even worse
10:19:34PMunchWorse?
10:20:02FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/950337020419506176/unknown.png
10:20:36*Zectbumo quit (Ping timeout: 240 seconds)
10:20:51*Zectbumo joined #nim
10:20:52PMunchI mean that doesn't tell me anything..
10:21:17FromDiscord<System64 ~ Flandre Scarlet> Well in fact the binding is imported in every module
10:21:31FromDiscord<System64 ~ Flandre Scarlet> like I have a module tilemap, it imports the binding
10:24:51PMunchThis works for me: http://ix.io/3RzA
10:25:38FromDiscord<System64 ~ Flandre Scarlet> ah so I need to redo the Futhark thing?
10:26:10PMunchWell, what I would do is move TilengineBinding.nim to TilengineBindingRaw.nim
10:26:27FromDiscord<System64 ~ Flandre Scarlet> I did a copy of TilengineBinding
10:26:33PMunchAnd then have `TilengineBinding.nim` be that type definition, and then `include TilengineBindingRaw` at the bottom
10:26:53PMunchThen you can `import TilengineBinding` like you did before
10:27:17PMunchBut I've gotta run
10:27:21PMunchLunch break!
10:27:25FromDiscord<System64 ~ Flandre Scarlet> sent a long message, see http://ix.io/3RzD
10:27:28FromDiscord<System64 ~ Flandre Scarlet> Good lunch!
10:29:28FromDiscord<System64 ~ Flandre Scarlet> Btw this is the Binding https://media.discordapp.net/attachments/371759389889003532/950339391002378270/TilengineBinding.nim
10:29:46FromDiscord<System64 ~ Flandre Scarlet> It's literally the futhark file
11:04:53*Gustavo6046 quit (Quit: Leaving)
11:10:30*Zectbumo quit (Remote host closed the connection)
11:20:16om3gaHi! What mean EDB in db/mysql? Is that constant(s), of what type or values? What I mean for example let db = open(..) .... if db == EDb: try... except... <-- will that work?
11:20:25FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://paste.rs/kJg
11:23:24*toulene quit (Ping timeout: 256 seconds)
11:24:33*toulene joined #nim
11:29:26*toulene quit (Ping timeout: 272 seconds)
11:32:06*toulene joined #nim
11:35:41PMunch@System64_~_Flandre_Scarlet, yeah I have the header and my own Futhark set up to wrap it :)
11:40:58*toulene quit (Ping timeout: 256 seconds)
11:42:40*rawrrr quit (Quit: Connection closed for inactivity)
11:44:04*krux02 joined #nim
11:50:04PMunchHmm, is there a way to do something like this in Nim? https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html
11:50:09PMunchI'm guessing there isn't, right?
11:54:21FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, yeah I have": And can you use it as expected?
11:54:47FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3RzZ
11:54:52FromDiscord<ynfle> In reply to @PMunch "Hmm, is there a": What's the purpose of this?
11:57:27FromDiscord<Rika> In reply to @ynfle "What's the purpose of": It is useful for unions I assume
11:58:15PMunch@System64_~_Flandre_Scarlet, yeah this works fine for me: http://ix.io/3RA0/nim
11:58:39PMunch@ynfle, @Rika, yes it's mostly for unions
11:59:50FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, yeah this works": ah alright, will try this, but I guess I need to re-Futhark the file again?
11:59:54PMunchYou could define something like http://ix.io/3RA0/c
12:00:07FromDiscord<Rika> There isn’t in Nim
12:00:14*jmdaemon quit (Ping timeout: 256 seconds)
12:00:22FromDiscord<Rika> Probably nearly trivial to implement via macro
12:01:02PMunchYeah I was thinking just some simple templates
12:01:11PMunch@System64_~_Flandre_Scarlet, nope
12:01:29PMunch@System64_~_Flandre_Scarlet, the file you have is exactly what would come from the cache right?
12:02:02PMunchYou remember all the `when declared` statements and the weird type pointing to a type pointing to a type stuff we looked at earlier?
12:02:12PMunchThat is to ensure that you can just drop in definitions like this
12:05:18FromDiscord<System64 ~ Flandre Scarlet> Oh alright
12:05:25FromDiscord<System64 ~ Flandre Scarlet> Okay so I changed the tile https://media.discordapp.net/attachments/371759389889003532/950363540634599454/unknown.png
12:06:01*supakeen quit (Quit: WeeChat 3.4)
12:06:30*supakeen joined #nim
12:07:23FromDiscord<ynfle> In reply to @PMunch "<@757977788056600719>, <@259277943275126785>, yes i": Nim doesn't have unions
12:07:52FromDiscord<Rika> Nim has unions
12:08:00FromDiscord<Rika> Pragma union
12:14:44FromDiscord<Waldecir Santos> How can I print only the pointer of a object "0x1022d52d0" ?
12:15:13FromDiscord<Waldecir Santos> I've tried `repr obj.addr` but it prints more than the ptr
12:15:52*jmdaemon joined #nim
12:16:04FromDiscord<Rika> Cast it into an appropriate size integer then format into a hex string
12:16:34FromDiscord<Waldecir Santos> Oh nice, let me try it, thank you
12:23:09*jmdaemon quit (Ping timeout: 256 seconds)
12:23:58PMunch@System64_~_Flandre_Scarlet, as I said, don't use Types.uniontile
12:24:15PMunchRather try to make sure that Futhark agrees with your definition
12:24:20PMunchLike I showed you in my example
12:24:45PMunchThat way you don't need the cast either, simply tile.addr should yield the correct type for setTilemapTile
12:29:30FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3RA8
12:32:06FromDiscord<Waldecir Santos> In reply to @Rika "Cast it into an": This is what I did `&"{cast[int](qs1.addr):#X}"` that is what you meant, right ?
12:33:36PMunch@System64_~_Flandre_Scarlet, as I've already told you three times, there was no need to re-futhark the file. Of course it doesn't hurt at all, but it wasn't really necessary. I'm not sure what you're asking about right now, you can move those definitions anywhere you like
12:33:59FromDiscord<Waldecir Santos> Funny that #X return the hex with upper case letters, but nim normally output them as lower case, /shrug
12:34:46FromDiscord<Waldecir Santos> Nope the problem is with `#X`, `#x` returns it lower case.
12:34:59FromDiscord<System64 ~ Flandre Scarlet> ah alright
12:38:11FromDiscord<System64 ~ Flandre Scarlet> But why doing the importc thing if I already have the futhark file?
12:40:00PMunch@System64_~_Flandre_Scarlet, if I where you I'd do something like this: https://play.nim-lang.org/#ix=3RAa
12:40:14PMunchWell Futhark is intended to be run whenever you compile your program
12:40:18PMunchThat's why it caches stuff
12:40:28PMunchSo that it will be fast
12:40:57FromDiscord<System64 ~ Flandre Scarlet> Aaaah alright!
12:41:00PMunchThe idea is that if I download a more recent version of Tilengine than the one you wrapped it will still work just fine
12:41:40FromDiscord<System64 ~ Flandre Scarlet> good to know↵And the Raw file, it is the old one right?
12:45:17PMunchThe Raw file is the cache file from Futhark, ref the comment on line 15
12:46:27PMunchI guess I could add a flag to Futhark to output to a specific file as well. That way the importc block could simply have a `output "TilengineBindingRaw.nim"` and that snippet would be self contained
12:47:18FromDiscord<System64 ~ Flandre Scarlet> The problem is the Windows file paths
12:47:25FromDiscord<System64 ~ Flandre Scarlet> it makes the tool bugged
12:47:50FromDiscord<System64 ~ Flandre Scarlet> since it understands ``\`` as an escape symbol
12:50:02FromDiscord<enthus1ast> sent a code paste, see https://paste.rs/I3d
12:50:20FromDiscord<enthus1ast> regarding nimscripter
12:58:44PMunch@System64_~_Flandre_Scarlet, "the tool"?
12:59:16FromDiscord<Rika> probably opir
13:05:58PMunchAh, someone who runs Windows and is good at Nim should really have a look at Futhark to fix the path handling
13:06:13PMunchI'd do it myself, but it's not exactly easy to do without a Windows machine :P
13:07:02FromDiscord<Rika> add "and also good at windows
13:07:23FromDiscord<Rika> i have windows, and am good enough at nim, but i have no clue how to do windows shit
13:07:32*rockcavera joined #nim
13:07:32*rockcavera quit (Changing host)
13:07:32*rockcavera joined #nim
13:14:31FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, "the tool"?": Futhark
13:14:57Amun-Raand I have the same ammount of winboxes as PMunch has
13:16:07*jjido joined #nim
13:16:41PMunch@Rika, haha yeah I need someone who fits the categories "Good at Nim", "Good at Windows", "Good at linking C stuff"
13:16:54PMunchI just need to get hold of Araq don't I :P
13:16:56FromDiscord<Rika> unicorn
13:17:01FromDiscord<Rika> youll have more luck finding a unicorn
13:17:05PMunchHaha
13:17:21PMunchI have a friend actually who's dabbled a bit in Nim, maybe he'd be able to help me out
13:21:30FromDiscord<enthus1ast> the only fix i found was import system/nimscript in os.nim
13:21:32FromDiscord<enthus1ast> ...
13:21:37FromDiscord<enthus1ast> bug i guess
13:50:17*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:52:14FromDiscord<System64 ~ Flandre Scarlet> How can I instanciate an anonymous object of a type please
13:52:27FromDiscord<Rika> ? wdym
13:53:17FromDiscord<System64 ~ Flandre Scarlet> In reply to @Rika "? wdym": I want to instanciate Tile objects in the loop https://media.discordapp.net/attachments/371759389889003532/950390682483318864/unknown.png
13:53:52FromDiscord<Rika> do you have an init proc for them?
13:54:20FromDiscord<System64 ~ Flandre Scarlet> no, why?
13:55:28FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=3RAw
14:03:38FromDiscord<System64 ~ Flandre Scarlet> Since when an int is immutable?↵It's not a constant https://media.discordapp.net/attachments/371759389889003532/950393292518989834/unknown.png
14:04:30FromDiscord<enthus1ast> the parametes to your function are
14:04:39FromDiscord<enthus1ast> must declare them with x\: var int
14:04:44PMunchI assume you wanted to change xTemp and not x?
14:04:59FromDiscord<enthus1ast> yes
14:05:07FromDiscord<System64 ~ Flandre Scarlet> ah yeah maybe I can do that
14:05:57PMunchYou could also alias them with `var x = x`. That way the parameter will still be immutable, but the number will be copied into a variable in your procedure
14:06:15FromDiscord<System64 ~ Flandre Scarlet> Ah alright
14:06:16*slowButPresent joined #nim
14:06:17PMunchAnd by the way, why do you have Tilemap.Tile, are you still not doing it how I told you to do this?
14:06:33FromDiscord<System64 ~ Flandre Scarlet> It's a bit disturbing, coming from Java and C
14:06:36PMunchIf you don't do it the way I told you it will likely mess up in a subtle way
14:06:41FromDiscord<Rika> what is Tilemap.Tile?
14:06:45PMunchWhat is a bit disturbing?
14:07:04FromDiscord<Rika> nim doesnt inherit much from C
14:07:17FromDiscord<System64 ~ Flandre Scarlet> I can't change the value of a parameter if it's not explicitly tell
14:07:32FromDiscord<Rika> thats good?
14:07:42FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "And by the way,": It conflicts with the original one
14:07:43FromDiscord<Rika> could be a subtle bug
14:08:25PMunch@System64_~_Flandre_Scarlet, that is my point exactly. The original one is the one that Futhark will use, so if you don't override it properly, like I showed you, it will likely bug out in subtle ways
14:10:04PMunch@System64_~_Flandre_Scarlet, of course you can't change the value of a parameter that's not explicitly defined as mutable. C and Java just does this aliasing with `var x = x` by default I believe. In Nim if you do `var int` as the type for a parameter it is analogous to passing in a pointer, it will modify the value you passed in.
14:25:17FromDiscord<System64 ~ Flandre Scarlet> Oooh alright!↵So even in C and Java, it was always constant!
14:26:57PMunchYup
14:28:18FromDiscord<System64 ~ Flandre Scarlet> Wow, it's good to know
14:38:35*PMunch quit (Quit: Leaving)
14:43:39*toulene joined #nim
14:58:01*toulene quit (Quit: Leaving)
15:00:41*PMunch joined #nim
15:04:30*arkurious joined #nim
15:08:56FromDiscord<System64 ~ Flandre Scarlet> it works well! https://media.discordapp.net/attachments/371759389889003532/950409722471809054/unknown.png
15:09:25FromDiscord<Rika> When the impostor is sus!
15:11:36FromDiscord<System64 ~ Flandre Scarlet> Tilengine is now sus!
15:20:53FromDiscord<abdu> what the Nim infinity set n range keyword symbol ?
15:21:31FromDiscord<Rika> huh?
15:22:31supakeenwhat the Nim infinity set n range keyword symbol ?
15:23:43PMunch-_-
15:25:53FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Yup": But is the importc thing necessary to override?
15:26:18PMunchWhat do you mean?
15:26:52FromDiscord<System64 ~ Flandre Scarlet> http://ix.io/3RA0/c↵Here
15:27:50PMunchStill not sure what you mean
15:28:13FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Still not sure what": from line 12 to 16
15:28:42PMunchYes that is the Futhark stuff
15:29:23FromDiscord<System64 ~ Flandre Scarlet> ah alright
15:32:05PMunchAs I said earlier, if you don't want your users to have to install Futhark I'd do it like this: https://play.nim-lang.org/#ix=3RBb
15:32:57PMunchThat way if you compile with `-d:useFuthark` it will use the Futhark and wrap the actual header, otherwise it'll grab the pre-generated version
15:33:27FromDiscord<Ookl> Why does it say I got tagged ?
15:33:54PMunchWho knows, maybe someone tagged everyone?
15:33:56FromDiscord<Rika> I do not know
15:34:16PMunchOr someone on IRC mentioned your name and it auto-converted to a tag :P
15:37:52*toulene joined #nim
15:39:33FromDiscord<System64 ~ Flandre Scarlet> Aaaah now I understand
15:42:29*PMunch quit (Quit: leaving)
15:53:29*jjido joined #nim
16:04:54*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
16:13:48*toulene quit (Quit: ZNC - https://znc.in)
16:20:56FromDiscord<Require Support> are vars under "when isMainModule" considered global? like can other procs access them
16:30:32*neurocyte0917090 joined #nim
16:36:57FromDiscord<SolitudeSF> \`when\` doesnt open new scope↵(@Require Support)
16:39:08*rockcavera quit (Ping timeout: 272 seconds)
17:08:02*rockcavera joined #nim
17:08:02*rockcavera quit (Changing host)
17:08:02*rockcavera joined #nim
17:18:58*oz quit (Remote host closed the connection)
17:59:37*ox joined #nim
18:08:29*jjido joined #nim
18:29:02*nexeq quit (Quit: WeeChat 3.4)
18:31:28FromDiscord<gibson> (sry, wrong channel before)↵Is anyone familiar with passing pointers from nim to py with nimpy? Someone asked in issues previously, but removed their own issue. Nimpy doesn't understand pointers so gets confused, and I'm unsure how to use PyCapsules in nimpy to accomplish this. I'd like to create a numpy array from a pointer to existing data (PyArray_SimpleNewFromData).
18:50:57FromDiscord<Require Support> quick way to convert string into char array?
18:52:36*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
18:52:50FromDiscord<huantian> In reply to @Require Support "quick way to convert": sequtils as toSeq
18:52:55FromDiscord<huantian> (edit) "as" => "has"
18:55:45FromDiscord<Generic> In reply to @Require Support "quick way to convert": char array as in array[n, char]?
18:56:06FromDiscord<auxym> In reply to @huantian "sequtils has toSeq": this will copy the string into the array, but yes it's probably the best way (unless you're interacting with C and just want to pass a bare pointer to the data)
18:56:17FromDiscord<gibson> `toOpenArray(x: cstring; first, last: int): openArray[char]` in system
18:56:22FromDiscord<Generic> yeah
18:56:39FromDiscord<Generic> there's also an overload which works on normal strings
18:57:01FromDiscord<gibson> (edit) "cstring;" => "string;"
19:00:03FromDiscord<Require Support> thanks guys
19:05:08FromDiscord<gibson> @Require Support there's also cstring: `myString.cstring` is a zero-copy type conversion to a Compatible String (basically pointer to the first char position)
19:06:00FromDiscord<Require Support> In reply to @gibson "<@!710108871724761128> there's also cstring:": omg, a life saver - that worked perfectly ❤️
19:09:32*droidrage quit (Quit: Gateway shutdown)
19:09:32*qwestion quit (Quit: Gateway shutdown)
19:27:00*mjsir911 quit (Remote host closed the connection)
19:27:15*mjsir911 joined #nim
19:29:39FromDiscord<Phil> Might I ask the more macro heavy folks among you something?
19:31:34FromDiscord<tandy> is there a way to convert `seq[string]` to `seq[cstring]`?
19:32:00FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3RCK
19:38:49*vicfred joined #nim
19:42:01*vicfred_ joined #nim
19:44:17*vicfred quit (Ping timeout: 240 seconds)
19:44:29FromDiscord<Phil> Wait a second
19:49:50FromDiscord<Phil> Ah yes, reading
19:49:55FromDiscord<Phil> one uses typed, the other ref object
19:50:11FromDiscord<Phil> Of course they're not going to work the same since dot is more specific than getField
20:20:50*jmdaemon joined #nim
20:28:14FromDiscord<gibson> In reply to @tandy "is there a way": For `seq[string]` to `seq[cstring]` I've been wanting that as well. AFAIK there is no way without looping through the data. You could theoretically do some fancy casting, but as I was recently advised on here, you should not assume the memory layout of the nim string datatype.
20:42:47FromDiscord<Generic> do you need a const char array for some c api?
20:44:32FromDiscord<Generic> also you need to be careful with a seq[cstring] the cstrings can very easily outlive their original strings
20:49:00*vicfred_ quit (Quit: Leaving)
20:49:35*vicfred joined #nim
20:54:14FromDiscord<auxym> there's the reverse here: https://nim-lang.org/docs/system.html#cstringArrayToSeq%2CcstringArray
20:55:05*Zectbumo joined #nim
21:27:28FromDiscord<Generic> that's where I was going
21:27:32*jjido joined #nim
21:27:52FromDiscord<Generic> you can use allocstringarray to convert a seq[string] to cstringarray
21:28:08*Gustavo6046 joined #nim
21:42:35*wyrd quit (Ping timeout: 240 seconds)
21:44:40*wyrd joined #nim
22:15:19FromDiscord<Elegantbeef> I think it requires a PR to the compiler to make it so it can work, looked at it briefly, there is an issue opened on nimscripter for it
22:16:26FromDiscord<enthus1ast> i patched my os.nim
22:16:59FromDiscord<Elegantbeef> Yea i read, that's not a solution though
22:17:07FromDiscord<enthus1ast> yes true
22:17:41FromDiscord<enthus1ast> imho just a conditional import was missing
22:20:21FromDiscord<asampal (Adrian Sampaleanu)> anyone know if the Windows build is currently working?
22:21:37nrds<Prestige99> for stable it is
22:22:12FromDiscord<asampal (Adrian Sampaleanu)> running from Powershell and getting pretty unexpected output\:↵`↵`
22:22:41FromDiscord<enthus1ast> [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org)\: i also don't know yet if nimscripter is the right route for me
22:22:44FromDiscord<asampal (Adrian Sampaleanu)> would expect it to try using the VS compiler
22:22:54nrds<Prestige99> asampal I don't see your output
22:23:54FromDiscord<Elegantbeef> Hey use whatever you want, there are issues with nimscripter when using nim modules that do need fixed or workarounds
22:24:29FromDiscord<Elegantbeef> Oh you're building fro msource
22:24:45FromDiscord<asampal (Adrian Sampaleanu)> as opposed to?
22:24:56FromDiscord<Elegantbeef> Getting a pre compiled binary
22:24:56FromDiscord<enthus1ast> no offence i just don't know yet what is better, another option i have is direct PNode generation, i guess nimscripter transforms NimNodes to PNodes?
22:25:07FromDiscord<enthus1ast> (better for my use case i mean)
22:25:11FromDiscord<Elegantbeef> Nimscripter transforms Nim code into pnodes and vice versa
22:25:24FromDiscord<Elegantbeef> It doesnt touch nimnodes
22:25:28FromDiscord<asampal (Adrian Sampaleanu)> well, a precompiled binary wouldn't be building it
22:25:54FromDiscord<Elegantbeef> Hey i thought the intent was getting a binary, my bad
22:26:23FromDiscord<Elegantbeef> You dont have gcc in your path
22:26:42FromDiscord<asampal (Adrian Sampaleanu)> I have Visual Studio installed though
22:26:52FromDiscord<asampal (Adrian Sampaleanu)> shouldn't the build use that?
22:26:52FromDiscord<Elegantbeef> In powershell I assume `gcc --version` doesnt work?
22:27:07FromDiscord<asampal (Adrian Sampaleanu)> nope
22:27:09FromDiscord<Elegantbeef> No it uses gcc by default, you might be able to force it to use vcc
22:28:15FromDiscord<Elegantbeef> Install mingw is what i'd say
22:28:55FromDiscord<Elegantbeef> Dont know where the build.bat file is so dont know how to force vcc to be used
22:29:01FromDiscord<asampal (Adrian Sampaleanu)> got WSL for Linux-y stuff
22:29:09FromDiscord<asampal (Adrian Sampaleanu)> don't use mingw any longer
22:29:45FromDiscord<asampal (Adrian Sampaleanu)> under Windows I would expect VS should be fine - I'll see what's needed to make it use that, I guess
22:30:05FromDiscord<Elegantbeef> Well mingw is what Nim defaults for a compiler on windows, so you have to override that to be vcc
22:30:16FromDiscord<Elegantbeef> It should be relatively simple i reason but i dont see how
22:31:43FromDiscord<Elegantbeef> Ah it's in the csources
22:32:01FromDiscord<Elegantbeef> https://github.com/nim-lang/csources_v1/blob/master/build.bat#L3-L4 setting these two flags after it clones the csources to be vcc might work
22:32:19FromDiscord<Elegantbeef> Then you have to pass `--cc:vcc` to all the nim commands
22:32:29FromDiscord<Elegantbeef> Or change your config to use vcc by default
22:35:37FromDiscord<Elegantbeef> [enthus1ast](https://matrix.to/#/@sn0re:matrix.code0.xyz)\: what're you working on anywho?
22:44:52FromDiscord<asampal (Adrian Sampaleanu)> sent a code paste, see https://play.nim-lang.org/#ix=3RDK
22:58:08anddamdo I need to reinstall packages after I upgraded 1.6.2 > 1.6.4 ?
22:58:28FromDiscord<gibson> In reply to @asampal (Adrian Sampaleanu) "got WSL for Linux-y": Make sure you are using the Visual Studio Development Terminal I forget what it's called but there's a shortcut in your Start menu somewhere. That will call the right script that sets a ton of VS/MS environment variables so nim can call the compiler tools correctly.
22:58:50FromDiscord<gibson> Do all your compiler stuff in that terminal.
23:00:47FromDiscord<gibson> https://docs.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022
23:16:32FromDiscord<gibson> Does anyone know a AoS/SoA library for nim? I thought there was an older one, but all I found was this: https://github.com/guibar64/aossoa
23:16:56FromDiscord<gibson> (edit) "this:" => "this by treeform:"
23:17:17FromDiscord<gibson> (edit) "this by treeform: https://github.com/guibar64/aossoa" => "this://github.com/guibar64/aossoa"
23:17:32FromDiscord<gibson> (edit) "this://github.com/guibar64/aossoa" => "this: https://github.com/guibar64/aossoa"
23:17:42*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
23:17:47FromDiscord<Elegantbeef> No you dont need to update packages
23:18:17FromDiscord<Elegantbeef> There is https://github.com/liquidev/datarray @gibson
23:18:52FromDiscord<gibson> @ElegantBeef Ah! That's it, thanks.
23:20:24FromDiscord<Elegantbeef> It's relatively easily to make with macros eitherway
23:24:18FromDiscord<gibson> I know, but I'm trying to keep the code that's here legible to newbs on the project, and using something that already has tests and docs as a black box of non-concern is easier for that purpose.
23:24:28FromDiscord<Elegantbeef> Ah
23:29:32*jmdaemon quit (Ping timeout: 272 seconds)
23:44:49*jmdaemon joined #nim
23:55:03FromDiscord<Alea> So I just saw that post about NimSkull↵Will existing libs be compatible with that?
23:55:47FromDiscord<Elegantbeef> Presently many, but as time goes on fewer and fewer
23:59:46FromDiscord<Elegantbeef> Anything with async will not work since they want to use CPS instead