<< 26-10-2021 >>

00:05:48FromDiscord<HuskyHacks> Hey Nim Discord, so @dom96 just came through one of the security research discords and hung out for a bit. The topic of the erroneous Defender triggers on the compiled binaries came up
00:06:25FromDiscord<HuskyHacks> if you want, I can help you find out exactly what is flagging in the Nim compiled binaries
00:06:34FromDiscord<HuskyHacks> The security community makes use of a tool called ThreatCheck to weaponeer payloads, i.e. find out which bytes Defender and AMSI are triggering on. But of course the same tool can be used to identify an erroneous Defender trigger for a legitimate binary and troubleshoot it from there
00:06:38FromDiscord<ynfle (ynfle)> Its a big issue for many newcomers
00:07:51nrds<Prestige99> When cross compiling from linux to windows and overriding libraries, do I need to download and point at the windows libs? Or should I only need the .so files?
00:08:37nrds<Prestige99> Attempting to link sdl2 and sdl_gpu to compile for windows
00:11:24nrds<Prestige99> Specifically trying --dynlibOverride:SDL2 --passL:/usr/lib/libSDL2.so `x86_64-w64-mingw32/bin/ld: /usr/lib/libSDL2.so: error adding symbols: file in wrong format`
00:11:37FromDiscord<impbox [ftsf]> you'll need the dll i believe
00:11:44FromDiscord<impbox [ftsf]> you don't need the .lib files
00:11:45nrds<Prestige99> ah, alright
00:16:32FromDiscord<impbox [ftsf]> `--passL:-lSDL` should do it i think
00:17:37nrds<Prestige99> I passed in the .dll and it seems to have worked
00:17:51nrds<Prestige99> only problem is now, is there's no dll for sdl_gpu
00:18:29FromDiscord<Elegantbeef> can you build it using mingw?
00:18:48FromDiscord<impbox [ftsf]> yeah
00:19:11FromDiscord<impbox [ftsf]> `-lSDL2` will work cross platform
00:19:19FromDiscord<impbox [ftsf]> so you don't need to specify the full path/name
00:19:25FromDiscord<Elegantbeef> well i meant for `sdl2_gpu`
00:19:31FromDiscord<impbox [ftsf]> but yeah, good luck with sdl2_gpu
00:19:51nrds<Prestige99> Weird, mine doesn't compile with --passL:-lSDL2
00:19:59nrds<Prestige99> cannot find -lSDL2
00:20:13FromDiscord<impbox [ftsf]> hmm probably not in your library path
00:20:24FromDiscord<impbox [ftsf]> `-L.` if it's in current dir
00:21:55nrds<Prestige99> in what way?
00:22:44nrds<Prestige99> (it works if I compile for linux but not windows, SDL2.dll is in the current dir)
00:27:41FromDiscord<impbox [ftsf]> ahh probably needs to be called libSDL2.dll
00:30:44nrds<Prestige99> rename it to that and do -d:mingw --dynlibOverride:SDL2 --passL:-lSDL ?
00:30:54FromDiscord<impbox [ftsf]> yep
00:30:56FromDiscord<impbox [ftsf]> -lSDL2
00:31:21nrds<Prestige99> hmm still x86_64-w64-mingw32/bin/ld: cannot find -lSDL2
00:31:58FromDiscord<impbox [ftsf]> and `--passL:-L.` to tell it to look in the current dir, or whatever path the library is in
00:32:29FromDiscord<impbox [ftsf]> unless it's under `x86_64-w64-mingw32/lib/`
00:32:43nrds<Prestige99> ah adding that --passL:-L. did the trick, thanks
00:33:19nrds<Prestige99> It actually expected it to be called SDL2.dll
00:34:39FromDiscord<impbox [ftsf]> oh ok then, sorry
00:34:52nrds<Prestige99> no worries 🙂 thanks for the help
01:16:51*neurocyte0132889 quit (Ping timeout: 260 seconds)
01:19:03FromDiscord<Hi02Hi> In reply to @eyecon "Can I initialize a": I don't think I saw a response, but in sequtils there is newSeqWith(), so `is_prime = new_seq_with(maxnum + 1, true)`
01:20:11FromDiscord<Elegantbeef> What was teh question? \:d
01:25:02FromDiscord<eyecon> In reply to @Hi02Hi "I don't think I": Ah, thanks
01:36:28*Jjp137 quit (Read error: Connection reset by peer)
01:39:15FromDiscord<impbox [ftsf]> missing out on the context in matrix it seems
01:40:04FromDiscord<Elegantbeef> Yea replies dont properly reply on the bridge
03:42:13*rockcavera quit (Remote host closed the connection)
03:46:37*Jjp137 joined #nim
04:06:02*supakeen quit (Quit: WeeChat 3.3)
04:06:31*supakeen joined #nim
05:50:13NimEventerNew thread by Vsajip: How do you get the actual exception from doAssertRaises?, see https://forum.nim-lang.org/t/8546
06:06:29FromDiscord<Rika> @beef regards the forum post this doesn’t assert that the exception is raised
06:07:25FromDiscord<Elegantbeef> Oh right
06:08:00FromDiscord<Elegantbeef> Thanks now it looks sillier but accomplishes
06:30:38*kenran joined #nim
07:00:12*PMunch joined #nim
07:11:46*pro joined #nim
07:14:16FromDiscord<Revenant> hey, just trying to get to confirm my observation that the 32-bit version of Nim seems to be quite badly broken, at least on Windows. using the latest 1.6.0 version
07:14:47FromDiscord<Revenant> which is sad, because then i can only provide 64-bit binaries to my users...
07:14:57FromDiscord<impbox [ftsf]> broken how?
07:15:43FromDiscord<Revenant> random memory violations, e.g. i'm passing a string to a simple proc, then the string suddenly changes address after a few loop iterations, resulting in a crash when compiled on 32-bits
07:15:48FromDiscord<Revenant> on 64-bits, no problems
07:16:12FromDiscord<Elegantbeef> Well make issues, but 32bit is quite a unicorn now
07:16:20FromDiscord<Revenant> in what sense?
07:16:32FromDiscord<Elegantbeef> If you can easily reproduce it i'd like to see the code
07:16:49FromDiscord<Elegantbeef> 32bit isnt a commonly used architecture anymore
07:17:13FromDiscord<Revenant> how about windows 7 users? quite a few are on 32-bit still, and there's still 32-bit win 10 installations around
07:17:16FromDiscord<Revenant> maybe not for linux 🙂
07:17:48FromDiscord<Elegantbeef> Supporting EOL software sound silly to me atleast
07:17:49FromDiscord<Revenant> ok, probably less than 10%... but that's still a few millions of people...
07:17:54madpropsisn't nim development made on windows?
07:17:59FromDiscord<impbox [ftsf]> it's still supported, so if you have a way to reproduce it worth filing an issue
07:18:08FromDiscord<impbox [ftsf]> but are you sure it's not user error?
07:18:11FromDiscord<Revenant> yeah that's fine too, but then they should remove the 32-bit installer from the website
07:18:15FromDiscord<Revenant> as i said, quite badly broken
07:18:27FromDiscord<Revenant> and state, "64-bits only"
07:18:29FromDiscord<impbox [ftsf]> are you wrapping C libs and not using the correct types
07:19:06FromDiscord<impbox [ftsf]> but yeah, we obviously want it to still work on win32, so if you have an example that isn't working, please share it so we can look into it
07:19:08FromDiscord<Revenant> could be, it's in my glfw wrapper project
07:19:36FromDiscord<Revenant> check this↵https://github.com/johnnovak/nim-glfw/blob/master/examples/glad/gl.nim#L3010
07:20:06FromDiscord<Revenant> so extname is just a string arg of that proc, and after a few iterations the pointer has a value of 8
07:20:08FromDiscord<Revenant> never a good thing 🙂
07:20:17FromDiscord<Revenant> maybe memory corruption?
07:20:24FromDiscord<impbox [ftsf]> well if you're corrupting memory it could be happening anywhere
07:20:29FromDiscord<Revenant> yeah
07:20:47FromDiscord<impbox [ftsf]> those types look dangerous
07:20:54FromDiscord<impbox [ftsf]> if they are int in c they should use cint
07:21:00FromDiscord<impbox [ftsf]> likewise unsigned int should be cuint
07:21:02FromDiscord<Revenant> you mean the {.cdecl.} stuff?
07:21:23FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3CUb
07:21:53FromDiscord<Revenant> ah yeah... that's doesn't look good
07:22:17FromDiscord<Revenant> well, it's been working on 64bit nim fine, it's the first time i'm trying it on 32bit
07:22:20FromDiscord<impbox [ftsf]> but you'd need to check the C header to check they're correct
07:22:27FromDiscord<Revenant> i'll try specifying the width for every type, etc
07:22:28FromDiscord<Revenant> thanks
07:22:30FromDiscord<impbox [ftsf]> yep, my guess is it's a mismatch in int size or something
07:22:54FromDiscord<Revenant> it would be good if it's something as simple as that 🙂
07:23:26FromDiscord<Revenant> i converted those manually from the official khronos opengl headers, those just use c types
07:23:42FromDiscord<impbox [ftsf]> yep, so if it says "int" in C, use "cint" in nim
07:23:48FromDiscord<impbox [ftsf]> and unsigned int -> cuint in nim
07:23:59FromDiscord<Revenant> they should be int32, clearly
07:24:06FromDiscord<Revenant> yeah okay
07:24:16FromDiscord<impbox [ftsf]> if they're int in C don't use int32
07:24:21FromDiscord<impbox [ftsf]> use cint
07:24:24FromDiscord<Revenant> okay
07:24:27madpropswhy is that?
07:24:47FromDiscord<impbox [ftsf]> because the c compiler needs to agree with nim about what size they are
07:24:49FromDiscord<Revenant> i thought ints in C are always 32-bit, then you have long for 64-bit ints
07:24:58FromDiscord<Revenant> but i guess that's only generally true, not always
07:26:04FromDiscord<impbox [ftsf]> int can be 64 bits on 64 bit linux, but it's up to the compiler
07:26:14FromDiscord<impbox [ftsf]> so you want to ensure they're using the same thing
07:26:27FromDiscord<impbox [ftsf]> so just remember int in C -> cint, unsigned int in C -> cuint
07:26:42FromDiscord<Revenant> yep, cheers
07:26:53FromDiscord<impbox [ftsf]> if the c header specifies a bit size, specify the same size
07:27:03FromDiscord<impbox [ftsf]> eg uint32_t -> uint32
07:38:27Amun-Raint has to be min. 16-bit
07:42:41FromDiscord<Rika> Huh?
07:43:00FromDiscord<impbox [ftsf]> in C
07:43:07Amun-Rayes
07:43:09FromDiscord<impbox [ftsf]> according to the spec i think
07:43:17Amun-Ramhm
07:44:05FromDiscord<impbox [ftsf]> has anyone targeted an 8 bit architecture with nim?
07:44:54FromDiscord<Elegantbeef> I figure the issue with that is the C compiler, unlikely you'd get C from Nim it could compile
07:45:01FromDiscord<Rika> Oh that’s what you mean
07:45:25FromDiscord<Rika> Yeah the sizes of int and unsigned are not specific numbers
07:45:36Amun-Raimpbox [ftsf]: I've found https://disconnected.systems/blog/nim-on-adruino
07:45:43PMunchimpbox_[ftsf], yup. On various microcontrollers
07:46:13FromDiscord<impbox [ftsf]> mmm arduino isn't 8 bit though is it?
07:46:25FromDiscord<impbox [ftsf]> i imagine someone might have targeted z80 for gameboy or something
07:46:29FromDiscord<Rika> It is afaik?
07:46:35Amun-Raarduino is not an architecture
07:46:39PMunchMost of them are I believe
07:46:45FromDiscord<Rika> The uno (base and most popular) is 8
07:46:50PMunchThe underlying chips of course
07:46:54FromDiscord<Rika> Duo and others are 32
07:47:02FromDiscord<impbox [ftsf]> ahh atmega328 is 8 bit, interesting
07:47:24PMunchI've used the ATmega32u4 in both a Leonardo and a Teensy 2.0, and it is 8-bit
07:47:43FromDiscord<impbox [ftsf]> cool
07:48:16FromDiscord<impbox [ftsf]> i've done some arduino stuff, never realised it was 8 bit though, only done teensy 3.6 which is 32 bit i think
07:48:24FromDiscord<impbox [ftsf]> need to try do some nim stuff with teensy
07:48:52Amun-Rateensy 3.6 uses ARM
07:48:55FromDiscord<Elegantbeef> Dont mention microcontrollers it just reminds me i've not done any more wrapping of the pico-sdk!
07:49:09supakeenArduino is both a bootloader and a 'standard library' that is implemented for many chipsets.
07:50:10PMunchOh yeah, I haven't looked at that any more either
07:50:32PMunchI still plan on wrapping all the AVR chips and setting up a common Nim ecosystem for microcontrollers
07:50:40PMunchBasically an alternative to Arduino
07:50:46supakeenYou should speak to dom on that :)
07:50:53supakeen(also that is a *lot* of work)
07:51:00PMunchI know
07:51:16FromDiscord<Elegantbeef> I dont have the hardware to continue wrapping the pico library
07:51:30supakeenYou'd be better off wrapping the ESP32 HAL (or Arduino) and to get support for Nim in platformio :)
07:51:36FromDiscord<Elegantbeef> Hard to test stuff you cannot test \:P
07:51:38supakeen(or writing a different toolchain for that bit)
07:51:41FromDiscord<impbox [ftsf]> i have a bunch of picos i have no use for
07:51:53supakeenElegantbeef: What hardware do you need?
07:51:58PMunchBut wrapping Arduino doesn't give us any benefits..
07:52:06FromDiscord<Elegantbeef> Actual shit to drive
07:52:20PMunchI mean my pure Nim -> AVR code is super fast and compact compared to Arduino
07:52:34FromDiscord<Elegantbeef> I guess i do have an arduino so i can technically test everything
07:52:46supakeenElegantbeef: name some stuff, radios? Sensors?
07:53:36FromDiscord<Elegantbeef> i2c stuff, pretty much anything more complex than just gpio operations
07:53:39supakeenOk.
07:54:13supakeenIf you PM me your address I can send you some stuff that speaks I2C, SPI, and I2S (some temperature, pressure, audio, dust, etc sensors).
07:54:22supakeenOnly if you want, of course :)
07:54:23FromDiscord<Elegantbeef> I do know one person uses my bindings and the i2c bindings seem to work (they printed their name to their scope)
07:55:08meowrayhow to create a seq[cint] from nums: ptr UncheckedArray[cint], n: int ?
07:56:36PMunchvar data = newSeqOfCap(n); for i in 0..<n: data.add nums[i]
07:57:07PMunchI guess you could also use memcpy
07:57:10FromDiscord<Rika> Collect where smh
07:58:08PMunchvar data = newSeq[cint](n); copyMem(data[0].addr, nums, n*sizeof(cint))
07:58:12PMunchSomething like that
07:59:20FromDiscord<Elegantbeef> `import std/sugar; var data = collect(newSeq): for i in 0..<n : nums[i]` for rika's sanity
08:00:05PMunchUnfortunately there is no way to create a seq without copying. This is simply because seqs are GCd, so you can't just make one frome any kind of data.
08:01:22FromDiscord<Elegantbeef> Depending what you're doing `nums.toOpenArray(0, n - 1)` could be used, but cannot be stored to a variable
08:02:02PMunchAh yes, that is true
08:02:28meowrayi fail to find an API converting `nums.toOpenArray(0, n - 1)` to a seq:( i go with `var a = newSeq[cint](n); for i in 0..<n: a[i] = nums[i] ` currently
08:02:59meowraythe drawback of `copyMem` is like `memcpy` vs `std::copy_n`. the former needs `sizeof(cint)` which is error-prone
08:03:55FromDiscord<Elegantbeef> Yea it doesnt convert to a seq, it converts it to an `openArray` as the name implies, which is useful if you're iterating or applying operations to it
08:05:06FromDiscord<Elegantbeef> Though to be able to use it easily without view types you'd probably want to do the unsafe thing of `template numsOa: openArray[cint] = nums.toOpenArray(0, n - 1)` but i digress
08:05:08meowraythe version i currently have:) https://github.com/MaskRay/LeetCode/blob/master/find-k-th-smallest-pair-distance.nim (yeah, i generate self-contained C with the help of https://github.com/goblint/cil/
08:06:53meowrayfollow-up question about testing: any better way than `let a = @[1,6,1].mapIt(cast[cint](it)).toSeq; echo smallestDistancePair(cast[ptr UncheckedArray[cint]](unsafeAddr a[0]), 3, 3)` ?
08:07:21FromDiscord<Rika> What the hell lol
08:07:35FromDiscord<Rika> Do you really need to go through so many hoops to do that
08:07:59FromDiscord<Rika> And what reason
08:11:29meowrayi know it's ugly but LeetCode's "C" language requires such an ugly function signature. https://0x0.st/-ddR.jpg
08:11:33FromDiscord<Elegantbeef> damn you cannot get a var open array from a pointer
08:12:44meowrayi use the approach from https://zen.su/posts/amalgamating-nim-programs/ (actually, https://maskray.me/blog/2021-09-26-competitive-programming-in-nim ) to get a self-contained C source file that I can submit on leetcode...
08:33:26*pro quit (Read error: Connection reset by peer)
08:34:01*pro joined #nim
08:39:21*pro quit (Quit: WeeChat 3.3)
08:46:25arkanoidis there any nim porgram/package known to be using CPS?
08:48:50FromDiscord<Elegantbeef> https://github.com/alaviss/nim-sys https://github.com/nim-works/loony
08:49:16FromDiscord<tandy> honestly tho, the team needs to hire someone to work on the compiler
08:49:20FromDiscord<tandy> maybe some more marketting too
08:49:45FromDiscord<tandy> if money is left over hire someone to make the js backend much more supported by stdlib, make stuff like jstring happen, etc
08:49:51FromDiscord<haxscramper> There are already people who are hired by status to work on compiler
08:49:59FromDiscord<tandy> moar
08:50:33FromDiscord<haxscramper> https://forum.nim-lang.org/t/8540#55418The fulltime paid devs are me and Narimiran; xflywind is paid for his work too but he is not a fulltime developer yet. We also sponsor Kiloneie's work on the "edutainment" YouTube videos.
08:50:37FromDiscord<Rika> 100k isn’t much to hire someone is it
08:50:59FromDiscord<Elegantbeef> It's enough for fulltime for a year roughly
08:51:19FromDiscord<Rika> “Me” being Araq by the way
08:51:45FromDiscord<haxscramper> Nim core devs have to come up with some shared vision for the language, and ecosystem and what we are aiming to advertise
08:51:56FromDiscord<haxscramper> But instead we are piling up new random features
08:52:06FromDiscord<haxscramper> 15 new stdlib modules, right
08:52:18FromDiscord<tandy> no not really↵(@Rika)
08:52:32FromDiscord<tandy> oh good to hear ur paid
08:52:40FromDiscord<Rika> Tandy read what I said
08:52:48FromDiscord<Rika> The “me” refers to Araq
08:52:51FromDiscord<haxscramper> "me" is araq
08:52:52FromDiscord<Elegantbeef> He's not that was a quote from araq
08:52:54FromDiscord<tandy> oh lmao↵(@Rika)
08:52:56FromDiscord<haxscramper> This is a quote from forum
08:53:00FromDiscord<Rika> Lol
08:53:01FromDiscord<tandy> fuck
08:53:03FromDiscord<haxscramper> I'm not getting paid shit
08:53:07FromDiscord<Elegantbeef> Hax loves ambiguity
08:53:20FromDiscord<Rika> Someone pay hax to complain about the state of Nim
08:53:29FromDiscord<tandy> i havent seen namiran in the repos much
08:53:30FromDiscord<haxscramper> Well, I write RFCs
08:53:37FromDiscord<haxscramper> Neither did i
08:53:38FromDiscord<Elegantbeef> Why would we pay him for something he does for charity 😛
08:53:53FromDiscord<haxscramper> He has been described earlier as a community manager
08:54:00FromDiscord<Rika> RFCs are just fancy complaints
08:54:08FromDiscord<haxscramper> Twitter/announcements/website maintenance and so on
08:54:08FromDiscord<Rika> I’m kidding
08:54:22FromDiscord<tandy> interesting, yeah i think i remember him tellin us off for offtopic in telegram chat
08:54:28FromDiscord<haxscramper> But that is true for the most part↵(@Rika)
08:54:57arkanoidwill nim ever takeoff?
08:55:21FromDiscord<haxscramper> Honestly - not sure
08:55:37FromDiscord<haxscramper> Not with current level of interest for promotion and driving people in
08:55:49FromDiscord<haxscramper> The language is good
08:56:10PMunchI think Nim is on a similar path to Python, a slow but steady incline
08:56:19FromDiscord<haxscramper> The people who manage it I have some complaints about
08:56:29FromDiscord<haxscramper> But the underlying idea is very good
08:56:35FromDiscord<Rika> The incline may be slow but I am not so sure about the steadiness
08:56:53FromDiscord<haxscramper> See commit pulse for the last year on GitHub
08:56:59FromDiscord<haxscramper> It looks like it is declining
08:57:26FromDiscord<haxscramper> image.png https://media.discordapp.net/attachments/371759389889003532/902481031989448704/image.png
08:57:36FromDiscord<Elegantbeef> I just think bug fixes/ promised features need to be realized
08:58:35FromDiscord<Elegantbeef> Many cases of people leave Nim is due to bugs in the present feature set
08:59:00emerymaybe some of use like nice, quiet, hipster languages
08:59:40FromDiscord<Rika> I wish there were less bugs but I haven’t encountered much so I’m not that fussed
08:59:50FromDiscord<xflywind> In reply to @haxscramper "https://forum.nim-lang.org/t/8540#55418The fulltime": precisely was paid in March this year
09:00:13arkanoidif you would leave nim, but keep working on system programming languages, where would you go today? C? Rust? Zig? Ada? Else?
09:00:15FromDiscord<Elegantbeef> Well i address the low hanging ones when i see them
09:00:24FromDiscord<tandy> would araq ever retire or something?
09:00:44FromDiscord<Elegantbeef> I dont like none of the alternatives really
09:00:46FromDiscord<haxscramper> I want to try out ada, but would probably go for rust↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
09:00:51FromDiscord<haxscramper> Zig is just too limiting
09:01:20FromDiscord<Elegantbeef> Nim gives me a bunch of stuff i feel is very nice for gamedev related stuff, the others dont do it as nicely imo
09:01:27FromDiscord<haxscramper> I like the language that give you options for rocket science reactor-tier complexity in your code
09:01:39FromDiscord<haxscramper> Cxx goes into this as well
09:02:21arkanoidI'm scared by Cxx, brainfuck is better in everything
09:02:40FromDiscord<haxscramper> I don't even know what is going on to be honest with this
09:03:10FromDiscord<haxscramper> There is literally zero effort to manage community expectations
09:03:26FromDiscord<haxscramper> like, this is the same discussion v5 IIRC
09:03:31FromDiscord<haxscramper> I had this rant already multiple times
09:04:49FromDiscord<haxscramper> so I'm going to spare your time, and summarize my complaints as - The underlying ideas for a language are extremely good, but due to lack of singular direction it feels like we are just rowing in circles without any aim, and I haven't seen any clear push from any of the core developers araq just listed to change this
09:05:04arkanoidthe two things that scare me the most are: antivirus problem on windows, general bus-factor 1 on many important modules
09:05:38FromDiscord<haxscramper> we are working on half a dozen fantastic features, while having ossified compiler codebase that everyone is too afraid to break because muh `--nimPreviewRandomGarbage`
09:06:23FromDiscord<haxscramper> that reminds
09:06:26FromDiscord<haxscramper> (edit) "that reminds ... " added "me"
09:08:52FromDiscord<haxscramper> In reply to @HuskyHacks "if you want, I": I suppose help like that would really be appreciated, though it could probably be discussed in the #internals channel, because as you can see #main has quite a lot of ongoing discussion, so there is a chance your message would simply go unnoticed
09:10:00FromDiscord<haxscramper> but damn this is depressing
09:10:21FromDiscord<haxscramper> this whole advertisement/management thing
09:11:43FromDiscord<haxscramper> I really want the language to succeed, and I hear all of these "2021 is a year of tooling", "we should focus on bugfixes" (every single commuity survery), "IC is the next big thing", get my hopes up
09:11:45FromDiscord<haxscramper> and then bam
09:11:53FromDiscord<haxscramper> 15 new stdlib modules with bus factor of 1
09:12:00FromDiscord<haxscramper> more garbage to maintain
09:13:26FromDiscord<tandy> i cri
09:13:28emeryi think it would be better to push new coders towards nim rather than experienced coders, but thats hard.
09:13:38FromDiscord<Elegantbeef> Hey setutils is nice!
09:13:45FromDiscord<haxscramper> yeah, everything is nice
09:14:09FromDiscord<haxscramper> the question is not whether modules are bad and all
09:14:12FromDiscord<Elegantbeef> I'm clearly joking cause I started it and added a few procs
09:14:33FromDiscord<haxscramper> but whether they should be the part of stdlib which increases maintenance burned on the langauge itself
09:16:48supakeenSome of them are indeed 'interesting'.
09:17:01supakeenI'm not that fond of things ending up in stdlib that say their API is 'experimental'.
09:17:25FromDiscord<haxscramper> we had fusion,
09:17:32FromDiscord<haxscramper> "supposedly"
09:17:40FromDiscord<haxscramper> except it is dead
09:18:11supakeenAnyways, you do have a point in that a large stdlib isn't necessarily good and a 'bad' stdlib reflects badly on the language.
09:18:32supakeenI should look at my old PRs and revive them.
09:19:18supakeenThey got marked by stale-bot recently.
09:19:34supakeenAnd I don't know if for example the header handling in the http stdlib things is now correct.
09:20:07supakeenI kinda went AWOL on this: https://github.com/nim-lang/Nim/pull/15478 :(
09:33:22*koltrast quit (Ping timeout: 258 seconds)
09:36:17FromDiscord<Kiloneie> Holy cow. https://media.discordapp.net/attachments/371759389889003532/902490809377652746/unknown.png
09:36:30FromDiscord<Kiloneie> This one is doing really well.
09:37:33FromDiscord<Kiloneie> If i recall correctly, my very first Nim video got 200 views after a MONTH. This one is 355 in 18 hours, yay.
09:37:54FromDiscord<Kiloneie> More interesting topics is the lesson here i believe.
09:38:20supakeenthings more people want/need :)
09:38:50FromDiscord<Kiloneie> ii mean 169 views on this one, but a high score of my channel either way.
09:38:52*koltrast joined #nim
09:39:06FromDiscord<Kiloneie> yeah, i need towrite a new list for this
09:39:14FromDiscord<dom96> Need more clickbait titles 🙂
09:39:15FromDiscord<Rika> What’s the retention?
09:40:04FromDiscord<Kiloneie> retention as in click trough rate or ? i don't understand D:
09:40:12FromDiscord<Rika> Watch retention
09:40:20FromDiscord<Kiloneie> oh , let me see
09:40:21FromDiscord<Rika> How long each view watches the video for
09:40:49FromDiscord<Kiloneie> well it says 4:52 min is the average on this one, which is btw huge, but i can get more info.
09:41:00FromDiscord<Rika> I personally wouldn’t call it a win if 90% of the views only watched like 10% of the video
09:41:08FromDiscord<Rika> Nice
09:41:18FromDiscord<Rika> That sounds okay, how long is the video
09:41:23FromDiscord<Kiloneie> 25 min video
09:41:31FromDiscord<Rika> Well that sounds good enough yes
09:42:24FromDiscord<Kiloneie> Heres how the rest of my top videos are doing https://media.discordapp.net/attachments/371759389889003532/902492347810611220/unknown.png
09:42:41FromDiscord<Kiloneie> For some reason people love Tables
09:43:28FromDiscord<Rika> I wish I could make videos but I already have my time split over so many projects
09:43:51FromDiscord<Kiloneie> It is a very time consuming thing to do.
09:44:29FromDiscord<Rika> I know, I’ve done it before
09:51:34FromDiscord<Hamid Bluri> In reply to @Kiloneie "It is a very": and when you make a mistake,.... you have to rerecord 😮‍💨
09:52:12FromDiscord<Hamid Bluri> i really want to make library
09:52:34FromDiscord<Hamid Bluri> to visualize/animate
09:53:33FromDiscord<Hamid Bluri> algorithms, but it seems quite hard
09:53:48FromDiscord<Hamid Bluri> (edit) "i really want to make ... library" added "a"
09:56:04FromDiscord<Hamid Bluri> i continue in `#offtopic`
09:56:47FromDiscord<Rika> In reply to @hamidb80 "and when you make": Some people make videos with minor mistakes but edit/handle it elegantly
09:57:52FromDiscord<xflywind> In reply to @haxscramper "so I'm going to": > I haven't seen any clear push from any of the core developers araq just listed to change this↵↵I'm not a core developer. Araq, dom96, timotheecour are core developers. I'm only being a member of Nim organization recently. Actually I worked for Nim for only one month in March.
09:59:35*tinytoast is now known as tinystoat
10:03:08arkanoidI have to say that I had that video playing yesterday night and I went sleep with my laptop on, and possibly the cats have been walking and restarting the video all night long
10:04:02FromDiscord<haxscramper> dom does not write a lot of code and is not paid to work on nim full-time IIRC↵(@xflywind)
10:04:08FromDiscord<haxscramper> well, "transparency"
10:07:07arkanoidoutside casual/hobby programmers, is the whole language rolling on 1 company and 3 people outside of it?
10:08:32FromDiscord<xflywind> In reply to @haxscramper "dom does not write": I think core developers mean making great contributions to Nim. And dom maintain nim-lang/nimble
10:09:54FromDiscord<xflywind> nether did timotheer get paid but he has been contributing to Nim
10:11:37FromDiscord<xflywind> In reply to @haxscramper "well, "transparency"": you can check the expenses of opencollective
10:12:13FromDiscord<Kiloneie> sent a long message, see http://ix.io/3CVd
10:12:31PMuncharkanoid, I use it for work. But I'm the only one at the company who does
10:13:30FromDiscord<xflywind> In reply to @flywind "you can check the": that should be all of the expenses of non-fulltime work
10:15:22FromDiscord<haxscramper> I think core developers mean full-time work on nim↵(@xflywind)
10:15:29FromDiscord<xflywind> In reply to @haxscramper "well, "transparency"": see https://opencollective.com/nim/expenses
10:15:32FromDiscord<haxscramper> "former core developer" yes, but
10:24:52*arkurious joined #nim
10:27:22FromDiscord<xflywind> In reply to @haxscramper "I think core developers": Make sense, but it also depends on how much they are paid
10:28:03FromDiscord<haxscramper> I don't think we would ever see exact numbers that are not on the opencollective
10:33:50FromDiscord<qb> Anyone a Idea how I could make `foobar` visible for `testlib` ? `dlsym` keep returning nil https://play.nim-lang.org/#ix=3CVh
10:33:58FromDiscord<qb> (edit) "keep" => "keeps"
10:36:07FromDiscord<haxscramper> https://nim-lang.org/docs/manual.html#foreign-function-interface-dynlib-pragma-for-export
10:36:32PMunch@qb, you might also want to use the dynlib module
10:39:20PMunchAnd you can't pass nil as the handle to dlsym I believe
10:42:28FromDiscord<qb> Mh not sure if dynlib makes sense. What I'm trying to do is to get a pointer to the foobar function provided by the main function from the library which is load
10:42:52FromDiscord<qb> (edit) "function" => "process"
10:45:00FromDiscord<qb> not sure if thats technically even doable
10:45:24PMunchShould be doable
10:47:36arkanoidPMunch: I also use it at work, but I'm the only IT man there, so it's just my preference
10:47:54arkanoid(working great so far)
10:50:22FromDiscord<qb> In reply to @PMunch "And you can't pass": `If handle is RTLD_DEFAULT, dlsym() searches all objects in the current process, in load-order. ` Guess ` define RTLD_DEFAULT ((void ) 0)` could be translated to `cast[pointer](0)` or just nil?
10:51:05PMunchJust nil should work there
10:59:04PMunchHmm, honestly not sure why this isn't working
11:01:25FromDiscord<qb> Alright. Was just for testing purposes
11:02:04PMunchIt's definitely possible to get a procedure from the program you're imported into though
11:02:16PMunchI do that in a DLL/so for work
11:10:06*kenran quit (Ping timeout: 245 seconds)
11:15:07PMunchHmm, so apparently passing --passL:"-Wl,--export-dynamic" to the binary makes it work
11:17:40PMunchAnd adding the `dynlib` pragma to the foobar proc
11:20:54FromDiscord<dom96> In reply to @haxscramper "I think core developers": I don’t think “core developer” should mean “paid full-time developer”
11:22:54FromDiscord<dom96> In reply to @haxscramper "dom does not write": Can confirm I’m not paid to work on Nim. Neither full-time nor part-time.
11:24:11PMunchOh wait, no this doesn't work at all..
11:33:25FromDiscord<eyecon> I'm taking a look at `std/streams`
11:33:39FromDiscord<eyecon> And I'm scratching my head as to how we would detect the end of file
11:33:51FromDiscord<eyecon> Do we just watch for an `IOError`?
11:34:24FromDiscord<eyecon> Use case: I'm writing, and will be reading back, a number of `uint32`s, but don't know where they end
11:34:33FromDiscord<eyecon> So I read until the end of the file into a seq
11:37:10FromDiscord<eyecon> I read https://forum.nim-lang.org/t/2787 and concluded that it might be an open point, but wanted to ask regardless
11:38:31FromDiscord<Rika> “at end” function
11:38:32FromDiscord<Rika> ?
11:39:31*casionaut joined #nim
12:00:28*kenran joined #nim
12:06:01*supakeen quit (Quit: WeeChat 3.3)
12:06:31*supakeen joined #nim
12:32:23*rockcavera joined #nim
12:32:23*rockcavera quit (Changing host)
12:32:23*rockcavera joined #nim
12:35:24Amun-Rais there a way of checking if type is distinct?
12:55:59*Vladar joined #nim
13:05:52FromDiscord<impbox [ftsf]> I'm sure there is at compile time
13:06:07FromDiscord<impbox [ftsf]> Using a macro you can inspect the typedef
13:07:52arkanoidAmun-Ra: https://play.nim-lang.org/#ix=3CW6
13:08:14arkanoidplease mind that it won't work in play.nim-lang.org as it's a compile time thing
13:09:35FromDiscord<narimiran> @arkanoid: click on "showing: output", and you can see compile-time stuff too 😉
13:11:09Amun-Raarkanoid: thanks
13:12:18arkanoidnarimiran, thanks for the correction
13:27:40FromDiscord<demotomohiro> !eval type DInt = distinct int; echo DInt is distinct
13:27:42NimBottrue
13:30:06arkanoidoh! that's new
13:30:26Amun-Rahmm
13:31:11arkanoiddemotomohiro, how did you found out that?
13:32:12FromDiscord<demotomohiro> https://nim-lang.org/docs/manual.html#generics-type-classes
13:33:19FromDiscord<Rika> !eval echo int is distinct
13:33:19FromDiscord<demotomohiro> I'm just using softweres after reading the manual :)
13:33:30NimBotfalse
13:39:15*rockcavera quit (Remote host closed the connection)
13:45:27arkanoiddemotomohiro, second name rainman?
13:52:56FromDiscord<forlorn> In reply to @haxscramper "Zig is just too": What in particular did you find limiting
13:56:46FromDiscord<demotomohiro> You don't need to remember eveythings in manual. If you know how type class works, you can get details of type class in manual just by searching for "type class".
13:57:05FromDiscord<forlorn> sent a code paste, see https://play.nim-lang.org/#ix=3CWk
13:58:32FromDiscord<forlorn> (edit) "https://play.nim-lang.org/#ix=3CWk" => "https://play.nim-lang.org/#ix=3CWl"
14:08:20FromDiscord<haxscramper> `int | float` is a compile-time thing. `union(int | float)` is a runtime thing
14:08:40FromDiscord<haxscramper> not really useful in procedure arguments, but if you want to return different types based on some runtime logic this is the only solution
14:12:33FromDiscord<IsaacPaul> Well I'm nitpicking, but it's not the _only_ solution lol
14:21:13FromDiscord<haxscramper> yes, you can create variant object of course
14:22:45arkanoidnever used union objects before, when should I use them?
14:25:08FromDiscord<IsaacPaul> On the readme for alaviss/union the use case was a making a value an optional (value vs None). If it supports it I'd see it being used to return union(result | error).
14:27:52FromDiscord<Rika> bet they are
14:33:01FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3CWu
14:33:52FromDiscord<Gumber> sent a code paste, see https://play.nim-lang.org/#ix=3CWv
14:34:04FromDiscord<IsaacPaul> really.. I should have just tried it then xD
14:34:07FromDiscord<IsaacPaul> (edit) "https://play.nim-lang.org/#ix=3CWu" => "https://paste.rs/Smh"
14:34:40FromDiscord<Gumber> the `importcpp` section of the manual holds all sorts of useful tips for learning how to make `importcpp` your biatch
14:34:57FromDiscord<Gumber> it's the only way you'll interop with C++
14:35:15FromDiscord<Gumber> is learning how to emit the correct C++ with it and `emit`
14:35:21FromDiscord<Gumber> and sometimes it's a real PITA
14:35:40FromDiscord<demotomohiro> Nim standard library has `option` module that can represent (value | none).
14:35:51FromDiscord<Gumber> and sometimes you just have no choice - like in the case of virtual classes / interfaces
14:35:58FromDiscord<Gumber> where you need to supply an implementation in userland
14:36:07FromDiscord<Gumber> you'll be stuck using `emit`
14:36:24FromDiscord<Gumber> or writing some C++ implementation and compiling it in your Nim code
14:37:00FromDiscord<Gumber> (edit) "userland" => "user land"
14:37:34FromDiscord<IsaacPaul> ah ok I skimmed over the importcc section. Reading it more thoroughly will help.
14:37:52FromDiscord<IsaacPaul> Just hate reading. I like doing lol
14:41:32FromDiscord<IsaacPaul> @Gumber Do you know any open source code that uses importcc for an interface that I can take a look at?
14:41:41FromDiscord<IsaacPaul> off the top of your head
14:44:20FromDiscord<demotomohiro> In Nim, unlike C/C++, you cannot do `a = b = c` to copy variable c to a anc b. Making `=` operator returns anything is not a Nim way. Because when you write `foo(a = b):` while you actually need to write `foo(a == b)`, compiler might not report error.
14:45:15FromDiscord<Rika> i assume the double equals was only done because he couldnt do `x := y` like he wanted
14:46:19FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3CWC
14:46:29FromDiscord<Gumber> In reply to @IsaacPaul "<@!204328759715692544> Do you": well I can share some of my code I use `importcpp` a lot
14:46:50FromDiscord<Gumber> I'll throw up my code later today on github but for now I can share a module
14:47:28FromDiscord<IsaacPaul> Awesome, I usually learn a lot more reading code over docs 😅
14:47:30FromDiscord<Gumber> here - I was wrapping steamworks with this from valve
14:47:51FromDiscord<Gumber> https://gist.github.com/zacharycarter/cb259acbde43effaae9c0d26fda5dab3
14:48:22FromDiscord<Gumber> they're not complete but what is there works
14:48:31FromDiscord<Gumber> so what is there is correct in other words 🙂
14:48:57FromDiscord<Gumber> only thing that COULD be missing is some `bycopy` pragmas but I've never had issues omitting those - even with the C++ backend
14:50:23FromDiscord<IsaacPaul> ah ok cool. I see what you did to handle callbacks awesome ya this helpful.
14:50:26FromDiscord<IsaacPaul> (edit) "ah ok cool. I see what you did to handle callbacks awesome ya this ... helpful." added "is"
14:54:48*kenran quit (Quit: WeeChat info:version)
15:29:52*casionaut quit (Remote host closed the connection)
15:39:45*Guest65 joined #nim
15:43:58*Guest65 quit (Quit: Client closed)
15:50:22FromDiscord<xflywind> https://www.reddit.com/r/programming/comments/qg2srd/nim_receives_100k_in_bitcoin_donations/
15:51:42FromDiscord<dom96> oh cool
16:12:56NimEventerNew thread by Pumpus: NIM IDE, see https://forum.nim-lang.org/t/8547
16:14:35nrds<Prestige99> Wasn't there a post exactly like this a few days ago/last week?
16:19:18FromDiscord<demotomohiro> This one?
16:19:19FromDiscord<demotomohiro> https://forum.nim-lang.org/t/8515
16:19:47*rockcavera joined #nim
16:19:47*rockcavera quit (Changing host)
16:19:47*rockcavera joined #nim
16:20:05nrds<Prestige99> Yep
16:23:10*PMunch quit (Ping timeout: 260 seconds)
16:25:05FromDiscord<haxscramper> NIM SHOULD NOT BE WRITTEN AS NIM incoming
16:29:11FromDiscord<dom96> Aporia 🪦
16:31:17nrds<Prestige99> no mention of moe?
16:31:34FromDiscord<IsaacPaul> I don't know if it's just me, but I can seem to get the nimsaem nim plugin to highlight syntax errors. Following symbols and autocomplete works tho
16:34:54FromDiscord<Rika> moe isnt really an ide
16:37:28nrds<Prestige99> what is it?
16:38:23FromDiscord<Rika> isnt it more like a regular traditional editor
16:40:54*vicfred joined #nim
17:04:34*PMunch joined #nim
17:10:35*PMunch quit (Ping timeout: 264 seconds)
17:12:04*PMunch joined #nim
17:35:08*neurocyte0132889 joined #nim
17:35:08*neurocyte0132889 quit (Changing host)
17:35:08*neurocyte0132889 joined #nim
17:45:19FromDiscord<dom96> wow, moe is so cool
17:45:58FromDiscord<dom96> I especially like how the number 1 feature on its website is "Written in Nim" :nim1:
18:11:20NimEventerNew thread by V3ss0n: Great to see Nim popularity rising , Top post of /r/programming on reddit now., see https://forum.nim-lang.org/t/8548
18:17:49FromDiscord<Yardanico> From that thread: apparently https://store.steampowered.com/app/1444480 is made with Godot and Nim
18:18:03FromDiscord<Yardanico> Will need to manually verify then add to the list :P
18:20:56FromDiscord<Yardanico> https://steamcommunity.com/app/1444480/discussions/0/2952663522496620840/
18:21:17FromDiscord<Yardanico> "strutils.nim(1115) parseInt↵Error: unhandled exception: invalid integer: [ValueError]" so at least some of it is Nim for sure :)
18:44:46FromDiscord<jos> are there any
18:44:50FromDiscord<jos> large open source nim projects
18:45:08FromDiscord<jos> preferably with some users
18:46:34FromDiscord<Yardanico> nitter
18:46:35FromDiscord<Yardanico> nim
18:47:32*neurocyte0132889 quit (Quit: The Lounge - https://thelounge.chat)
18:47:47msthuh, had never occurred to me that's why nitter was called that
18:53:48*neurocyte0132889 joined #nim
18:53:48*neurocyte0132889 quit (Changing host)
18:53:48*neurocyte0132889 joined #nim
19:01:14FromDiscord<reilly> Compiling something for a Raspberry Pi using a custom build script, and getting this error I've never seen before: `/usr/bin/ld: /home/pi/Desktop/nanolab-gui/gui/.nimcache/stdlib_unicode.nim.cpp.o: file not recognized: file truncated`
19:04:02FromDiscord<reilly> Deleting the `.nimcache` folder did the trick. A build must have gotten interrupted earlier and I didn't know it...
19:04:25FromDiscord<IsaacPaul> yea I was going to say it seems like the linking couldn't finish parsing the object file
19:13:10FromDiscord<demotomohiro> Maybe the sdcard your Raspberry PI using is going to die.
19:14:33FromDiscord<demotomohiro> I heard using sdcard with Raspberry PI doesn't last long time and I lost a sdcard used with raspberry PI 3.
19:16:14FromDiscord<reilly> I can worry about a dying SD card later, right now I'm wonder why `glfwCreateWindow()` isn't working on the RPi.
19:17:28FromDiscord<reilly> sent a code paste, see https://play.nim-lang.org/#ix=3CYX
19:23:59FromDiscord<reilly> Well, I half-solved it. It's still failing to create the window, but instead of failing inside of `glfwCreateWindow()`, it's failing in my own assertion instead. The window is always nil but I don't know why.
19:30:32FromDiscord<Goel> Wasn't 1.6 going to change the `gc` of Nim to `arc`/`orc` by default? I see the default is still `refc`
19:32:19FromDiscord<demotomohiro> You are trying to create a window with OpenGL version that is not supported by raspberry pi?
19:34:43FromDiscord<deech> How do I check to see if the current backend is `cpp` inside a macro?
19:35:14FromDiscord<Elegantbeef> `when defined(cpp)`
19:35:36FromDiscord<Elegantbeef> or just `let isCpp = defined(cpp)`
19:36:08FromDiscord<deech> Duh! Thanks!
19:36:26FromDiscord<Elegantbeef> No problem, and forgot to say good talk on tuples 😛
19:37:46FromDiscord<deech> Thanks!
19:38:14FromDiscord<reilly> sent a code paste, see https://play.nim-lang.org/#ix=3CZ4
19:38:39FromDiscord<reilly> Now I'm worried that NimGL just doesn't support older OpenGL versions...
19:40:04FromDiscord<Elegantbeef> That's the gflw version no?
19:41:02FromDiscord<demotomohiro> NimGL just wrap GLFW for Nim. It should support any OpenGL version GLFW supports.
19:41:47FromDiscord<reilly> "NimGL only supports modern OpenGL." - the readme
19:42:32FromDiscord<reilly> In reply to @Elegantbeef "That's the gflw version": As far as I can tell, that is how you specify your OpenGL version.
19:43:41FromDiscord<reilly> I actually hadn't tried it on the RPi without using the `GLFWOpenglProfile` hint until a minute ago, and that actually does initialize the window properly.
19:44:38FromDiscord<reilly> The problem now is that it "failed to compile vertex shader," telling me that GLSL 3.30 is not supported and that only 1.10, 1.20, 1.00 ES, and 3.00 ES are.
19:51:25FromDiscord<Gumber> moden opengl meaning anything not legacy opengl
19:51:33FromDiscord<Gumber> 2.1 is still modern opengl
19:51:48FromDiscord<Gumber> you should probably be using GLES if you want to write OpenGL for a raspberry Pi
19:53:10FromDiscord<Gumber> sent a code paste, see https://paste.rs/QEl
19:53:35FromDiscord<Gumber> you need to specify the version of GLSL you're shaders should be compiled against in the shaders themeslves
19:53:45FromDiscord<Gumber> it has nothing to do with the version of the OpenGL graphics context you created
19:53:58FromDiscord<Gumber> (edit) "you're" => "your"
19:54:01FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3CZ9
19:54:13FromDiscord<Gumber> yeah this has nothing to do with GLFW honestly
19:54:21FromDiscord<Gumber> its user error / not knowing enough about OpenGL
19:54:28FromDiscord<Gumber> (edit) "yeah this has nothing to do with GLFW honestly ... " added "or Nim or NimGL"
19:54:50FromDiscord<Gumber> (edit) "its user error / not knowing enough about OpenGL ... " added "& GLSL"
20:12:36FromDiscord<Alea> so you can use unicode operators↵has anyone ever implemented APL in nim?
20:15:32FromDiscord<Elegantbeef> You can use a limited selection of unicode operators
20:18:49FromDiscord<haxscramper> you can use any unicode if you are wiling to deal with the resulting AST
20:19:20FromDiscord<haxscramper> `ф у н к ц и я(12 ∈ 123)` is technically valid IIRC
20:20:02FromDiscord<haxscramper> https://wandbox.org/permlink/o6heAvejNox2xKAP
20:20:03FromDiscord<haxscramper> yes
20:20:22FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#lexical-analysis-unicode-operators
20:21:37FromDiscord<haxscramper> tbh we should've enabled this from the start
20:21:42FromDiscord<haxscramper> nobody uses these operators anyway
20:22:55FromDiscord<haxscramper> if you want some traditional APL you might also write things in a single operators and then split them
20:23:07FromDiscord<haxscramper> Like `#$%^&I(` and then iterate over runes
20:59:31nrds<Prestige99> Is there a preferred way to handle having a ref and non-ref version of the same type?
20:59:43nrds<Prestige99> I guess a standard
21:01:02*Vladar quit (Quit: Leaving)
21:08:06FromDiscord<haxscramper> define regular type as object and the do `A = ref B`. If you plan to use ref more often then name original object like `NimNodeObj` and ref version should be named `NimNode`
21:08:22FromDiscord<haxscramper> IIRC this is a recommended way/style to deal with this
21:08:48nrds<Prestige99> Cool, thanks
22:12:14FromDiscord<lenis> Is there any way to wrap c functions and trace the pointers that it returns?↵Say it returns a struct type with pointers to other strucs, anyone know if you can convert those to refs?
22:17:01FromDiscord<Elegantbeef> you cannot convert to refs without making refs and setting the internals
22:17:23FromDiscord<Gumber> is that true?
22:17:42FromDiscord<Elegantbeef> Well safely
22:17:52FromDiscord<Elegantbeef> You can cast to a ref all day long but it's not going to be properly managed
22:18:07FromDiscord<Gumber> well no I don't mean cast to it
22:18:18FromDiscord<Gumber> oh you want to convert it to a ref I see
22:18:46FromDiscord<Gumber> yes that'd be trickier
22:19:17FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3CZO
22:19:30FromDiscord<Elegantbeef> Assuming theStruct is a `ptr T` and `YourRefType` is `ref T`
22:20:36FromDiscord<Gumber> but yeah there are obvious dragons lurking here
22:20:46FromDiscord<Gumber> depending on what you're doing across the interop boundary
22:21:24FromDiscord<Elegantbeef> Yea as always using a ref -\> C is dangerous if you dont know what it's doing with the ref
22:21:45FromDiscord<Elegantbeef> But if you're staying in Nim land this is a safe solution assuming you want to use C to create some stuff then use it in Nim as a Nim type
22:22:00FromDiscord<Gumber> well maybe it's safe
22:22:21FromDiscord<Gumber> unless Nim collects the memory and then C tries to access it later
22:22:36FromDiscord<Gumber> or whatever other weird stuff could happen
22:22:50FromDiscord<Gumber> you really need to know what your C code is doing
22:22:54FromDiscord<Elegantbeef> Well i was saying C had no interaction with the output C
22:23:02FromDiscord<Elegantbeef> output C struct
22:23:15FromDiscord<Elegantbeef> Of course if it's interacting/expecting it to be there later it's dangerous
22:23:16FromDiscord<Gumber> I assume C is calling into Nim here or Nim is calling into C and C is returning something to Nim
22:23:20FromDiscord<Gumber> yeah
22:23:28FromDiscord<Gumber> just need to be aware of what you're doing is the message I think
22:23:34FromDiscord<Elegantbeef> It's really a question of what is the C code doing and in the C struct/ what you're doing 😛
22:23:38FromDiscord<lenis> in this case im calling a C function which returns data that I then use in nim, never returning to the C library
22:23:50FromDiscord<Gumber> then you're fine
22:23:52FromDiscord<Elegantbeef> Well then yes my example will work if C never expects data to persist
22:24:02FromDiscord<lenis> but would that work if YourRefType has pointers inside of it
22:24:23FromDiscord<Gumber> those would all need to get boxed
22:24:26FromDiscord<Elegantbeef> It'd work but you'd need to add a destructor hook to manage those pointers for you
22:24:29FromDiscord<lenis> type YourRefType = object↵ prop: string↵ otherRefType: ptr MyOtherType
22:24:33FromDiscord<Elegantbeef> Or box those
22:24:34FromDiscord<Gumber> well they wouldn't be managed by the GC
22:24:37FromDiscord<Gumber> unless you box them as well
22:25:00FromDiscord<Elegantbeef> Well the destructor for the `YourRefType` could though afaik
22:25:05FromDiscord<Gumber> yeah
22:25:12FromDiscord<Gumber> well you can't create destructors for ref types
22:25:32FromDiscord<Gumber> only objects
22:26:10FromDiscord<Gumber> if you want the pointers to be traced GC references you need to create refs for the objects
22:26:13FromDiscord<lenis> I actually tried defining a destructor but i got an error saying a destructor was already implicitly defined
22:26:17FromDiscord<Gumber> as far down the hierarchy as you want to go
22:26:39FromDiscord<Gumber> the GC will then clean up the underlying memory when it goes out of scope
22:26:53FromDiscord<Gumber> you could create a destructor for your `object` that wraps your C struct
22:26:58FromDiscord<Gumber> and then create a ref type from that
22:26:59FromDiscord<lenis> `var yourRef: YourRefType` implicitly defined a destructor i think
22:27:04FromDiscord<Gumber> and clean up the pointers in the object's custom destructor
22:27:10FromDiscord<Gumber> yeah - you can define custom destructors for ref types
22:27:13FromDiscord<Gumber> but you can do:
22:27:32FromDiscord<Elegantbeef> I always forget destructor rules
22:27:37FromDiscord<Elegantbeef> Cant distincts get destructors?
22:28:07FromDiscord<Yardanico> In reply to @lenis "I actually tried defining": That is usually a problem when you use the type before it's defined
22:28:08FromDiscord<Gumber> and then handle whatever there
22:28:10FromDiscord<Gumber> sent a code paste, see https://paste.rs/NBD
22:28:25FromDiscord<Gumber> oh and yes you need to define the destructor before you reference the type anywhere else
22:28:42FromDiscord<Yardanico> (edit) "it's" => "the destructor is"
22:30:23*arkurious quit (Quit: Leaving)
22:34:23FromDiscord<lenis> In reply to @Yardanico "That is usually a": Thanks, that fixed it
22:34:26FromDiscord<lenis> I should have known lol
22:35:09FromDiscord<lenis> ok, i think i have it working, even though its a bit janky. I had to include a pointer to itself to pass back to the C function to free the raw pointer
22:35:15FromDiscord<lenis> because the ref creates a new pointer
22:35:23FromDiscord<lenis> but I think its working, thanks guys 🙂
22:48:22FromDiscord<resumin> sent a long message, see http://ix.io/3CZU
22:53:47FromDiscord<Elegantbeef> If you make the gen a macro you invoke you can, but otherwise you cannot, might be able to use a generic instead for this though somewhat boilerplatey
22:56:10FromDiscord<resumin> Ok, thanks. I don't think the enum and array will need extended on a normal basis, so it seems reasonable to use what I currently doing and splitting it up.
22:59:36FromDiscord<Elegantbeef> Like this would work https://play.nim-lang.org/#ix=3CZX
22:59:54FromDiscord<Elegantbeef> I guess the concept should add `E is enum`
23:01:17FromDiscord<Elegantbeef> It's of course not extendable across module boundaries but it's a simpler more concrete solution
23:03:03FromDiscord<resumin> That's pretty cool. I haven't made use of concepts.↵↵I have an enum that identifies operating systems and cpus and corresponding arrays that hold detailed information for enum value. I'll push it to a repo. just a moment
23:14:45FromDiscord<resumin> https://github.com/quantimnot/platforms
23:47:52FromDiscord<Elegantbeef> [resumin](https://matrix.to/#/@resumin:matrix.org)\: so yea you could make an `implOS` macro which emits the code you need, similar to what i do with nimscripter here https://github.com/beef331/nimscripter/blob/bigrewrite/src/nimscripter/expose.nim#L292
23:54:51FromDiscord<lenis> sent a code paste, see https://play.nim-lang.org/#ix=3D09
23:55:56FromDiscord<Elegantbeef> wait until you leanr of `ptr UncheckedArray[int](p)[i]` 😀
23:56:19FromDiscord<lenis> aw man i knew there had to be an easier solution
23:56:30FromDiscord<lenis> thanks
23:56:55FromDiscord<Elegantbeef> You can also do `for x in cast[ptr UncheckedArray[T]](p).toOpenArray(0, count - 1)`
23:58:31FromDiscord<lenis> does that account for the size of each element?
23:58:53FromDiscord<Elegantbeef> Well elements are considered `sizeof(T)`
23:58:56FromDiscord<lenis> oh yeah it should
23:59:05FromDiscord<lenis> yeah cool, thanks
23:59:26FromDiscord<Elegantbeef> Though sadly that's a read only openArray
23:59:56FromDiscord<lenis> yeah thats fine