<< 18-04-2023 >>

01:09:18*nanxiao joined #nim
01:21:37*noxp quit (Quit: Leaving)
02:08:36*nanxiao quit (Quit: Client closed)
02:49:26*nanxiao joined #nim
02:55:28*cm quit (Ping timeout: 248 seconds)
02:59:54*cm joined #nim
03:14:01*lucasta quit (Ping timeout: 240 seconds)
03:33:10FromDiscord<JeysonFlores> if there any idiomatic way to dynamically add parameters to a varargs function? something like the unpack() operator in Python.
03:34:48FromDiscord<JeysonFlores> sent a long message, see http://ix.io/4tGc
03:35:00FromDiscord<JeysonFlores> (edit) "http://ix.io/4tGc" => "http://ix.io/4tGd"
03:35:37FromDiscord<JeysonFlores> (edit) "http://ix.io/4tGd" => "http://ix.io/4tGe"
03:36:14FromDiscord<JeysonFlores> (edit) "http://ix.io/4tGe" => "http://ix.io/4tGf"
03:44:48FromDiscord<demotomohiro> In reply to @JeysonFlores "is there any idiomatic": https://nim-lang.org/docs/manual.html#types-varargs↵> A varargs parameter is an openarray parameter that additionally allows to pass a variable number of arguments to a procedure. The compiler converts the list of arguments to an array implicitly:
03:50:25FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4tGi
03:53:34FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4tGj
03:54:10FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4tGk
03:55:25FromDiscord<demotomohiro> https://nim-lang.org/docs/manual.html#types-varargs↵> A varargs parameter is an openarray parameter
03:56:19FromDiscord<demotomohiro> That means you can pass array or seq to varargs.
04:03:08FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4tGm
04:11:17FromDiscord<Elegantbeef> I will say using multiple varargs is a bit suspect
04:11:39FromDiscord<Elegantbeef> There are compiler bugs related there
04:26:49*nanxiao quit (Quit: Client closed)
04:48:08FromDiscord<user2m> havn't found a use case of it yet just learning
05:12:55FromDiscord<sOkam!> when doing interop with C, is it safe to map `uint32_t` as `uint32` instead of `cuint` or similar variations for other type sizes?
05:13:04FromDiscord<Elegantbeef> Yes
05:13:45FromDiscord<Elegantbeef> Fixed size types are fixed size which makes the interop so much more sane
05:16:05FromDiscord<sOkam!> so the ctypes should be used when the size is not fixed?
05:16:11FromDiscord<Elegantbeef> Yes
05:16:16FromDiscord<sOkam!> kk
05:16:43*nanxiao joined #nim
05:40:19*derpydoo joined #nim
05:49:13*rockcavera quit (Read error: Connection reset by peer)
05:49:33*rockcavera joined #nim
05:49:33*rockcavera quit (Changing host)
05:49:33*rockcavera joined #nim
05:58:03*tiorock joined #nim
05:58:03*tiorock quit (Changing host)
05:58:03*tiorock joined #nim
05:58:03*rockcavera quit (Killed (copper.libera.chat (Nickname regained by services)))
05:58:03*tiorock is now known as rockcavera
06:10:46*fredrikhr joined #nim
06:12:45*nanxiao quit (Quit: Client closed)
06:29:41Amun-RasOkam!: min. cuint size is 16-bit
06:33:06*kenran joined #nim
06:34:20*nanxiao joined #nim
06:38:16*PMunch joined #nim
06:51:54*advesperacit joined #nim
07:03:38*ltriant quit (Ping timeout: 265 seconds)
07:04:35*Batzy quit (Ping timeout: 260 seconds)
07:08:31*Batzy joined #nim
07:17:09PMunchIs this going to stay a thing in 2.0? Error: invalid order of case branches
07:17:53FromDiscord<Elegantbeef> That's a thing?
07:17:59PMunchApparently
07:18:12PMunchI get this error when I try to compile a project which uses Protobuf
07:18:25PMunchLike this: /home/peter/.nimble/pkgs/protobuf-0.5.2/protobuf.nim(537, 7) Error: invalid order of case branches
07:18:48FromDiscord<Elegantbeef> Oh seems like it's for `of` before or after `elif`/`else`
07:18:48PMunchBasically it generated a case statement based on the stuff in the protobuf file
07:19:15PMunchSuper annoying though, like why would that be disallowed?
07:19:25FromDiscord<Elegantbeef> Oh not
07:19:29FromDiscord<Elegantbeef> or not\
07:20:19*cnx quit (Remote host closed the connection)
07:21:06*cnx joined #nim
07:23:45FromDiscord<Elegantbeef> It's likely for definitive analysis
07:23:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tGL
07:25:16NimEventerNew thread by nimnam: Which might be the best way to store complex data in MySQL, see https://forum.nim-lang.org/t/10109
07:26:41FromDiscord<ringabout> In reply to @PMunch "Super annoying though, like": It is a bug fixing => https://github.com/nim-lang/Nim/pull/20862 it is perhaps more consistent?
07:27:15FromDiscord<Elegantbeef> It can only be done through macros and it's not too hard to just delay the add until the end
07:27:41FromDiscord<Elegantbeef> The parser stops scanning for `of` after an `else` anyway so it's atleast more corrrect
07:28:37PMunchThis code has worked for ages though
07:28:51PMunchSo no idea why it stopped working now
07:28:55FromDiscord<Elegantbeef> Is this where i say 2.0 or something 😄
07:29:47FromDiscord<Elegantbeef> It didnt evaluate properly with strings so the rule was enforced across types
07:31:10FromDiscord<Elegantbeef> I'd personally argue you were generating incorrect code and the compiler just happened to handle it correctly
07:32:06FromDiscord<Elegantbeef> Yes no one asked
07:33:05*rockcavera quit (Remote host closed the connection)
07:53:21*nanxiao quit (Quit: Client closed)
08:02:41*nanxiao joined #nim
09:05:48*nanxiao quit (Quit: Client closed)
09:34:32*Notxor joined #nim
09:52:06FromDiscord<Yardanico> Is it documented in the changelog? I think changes like those should be in it
10:04:01*jmdaemon quit (Ping timeout: 240 seconds)
10:19:25*derpydoo quit (Ping timeout: 260 seconds)
10:23:16NimEventerNew thread by alexeypetrushin: How to inverse set?, see https://forum.nim-lang.org/t/10110
11:23:26FromDiscord<Groot> i am trying to create a nim program with keepalive tcp server and client but keepalive is not working , how it can be fixed?
12:00:42FromDiscord<sOkam!> If you have a `let data: ptr UncheckedArray[uint8] = ...`, that you know is length N, how do you iterate through its values?
12:08:46PMunch`for i in 0..<N: echo data[i]`
12:09:10PMunchOr maybe it's `data[][i]` don't remember if they auto-dereference
12:09:19PMunchBut I think they do
12:14:27FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4tHr
12:14:41FromDiscord<sOkam!> its printing jibberish for some reason, which is why I wanted to confirm
12:14:57FromDiscord<sOkam!> If i do `data[][0]` it prints the exact same `16` value
12:15:53FromDiscord<sOkam!> (edit) "https://play.nim-lang.org/#ix=4tHr" => "https://play.nim-lang.org/#ix=4tHs"
12:18:08PMunchThat is because you're not casting correctly
12:18:15PMunchLet me guess, you're casting a sequence?
12:18:44PMunchThat 16 and "gibberish" is likely the length of the data along with a pointer
12:18:55FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4tHt
12:19:27FromDiscord<sOkam!> and i send it to the gpu with `queue.writeBuffer(buffer1, 0, numbers.addr, 16)`
12:19:31PMunchYeah, so casting a seq[uint8] to `ptr openarray[uint8]` isn't valid
12:19:43PMunchWell it's valid, but it's not correct
12:19:57PMunchTry `numbers[0].addr`
12:20:26FromDiscord<sOkam!> omg if thats what it is.... ive done that like 10000million times before
12:20:35PMunchBut keep in mind that you're now creating a pointer to memory which is garbage collected by Nim, so if that data goes out of scope the memory will be freed even if you have a pointer to it
12:20:38FromDiscord<sOkam!> let me confirm
12:20:52FromDiscord<sOkam!> In reply to @PMunch "But keep in mind": true that
12:21:13PMunchnumbers.addr will be a pointer to the sequence itself, not the data within it
12:21:48FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4tHv
12:22:00FromDiscord<sOkam!> ty so fucking much, pmuch 🙏
12:22:11FromDiscord<sOkam!> (edit) "pmuch" => "pmunch"
12:24:33FromDiscord<cmc> Don't worry, you brain will be very motivated to process more data faster because of this. It will save you a lot of time in the long run, even if you can't directly trace it to this experience.↵(@sOkam!)
12:24:49FromDiscord<sOkam!> 😄
12:25:35FromDiscord<sOkam!> how can I find the underlying structure that holds a sequence? meaning the underlying type. i was never able to find it on the system module, but maybe i was searching wrong
12:31:07*ltriant joined #nim
12:33:34FromDiscord<Rika> You won’t because it’s embedded in the compiler
12:34:39PMunchIsn't it found in nimbase.h?
12:35:05PMunchBut yeah, it's not found anywhere within Nim itself
12:47:33FromDiscord<amadan> In reply to @sOkam! "how can I find": The one used by orc/arc is defined here https://github.com/nim-lang/Nim/blob/devel/lib/system/seqs_v2.nim#L25↵Zero clue where the old version is defined
12:54:03FromDiscord<sOkam!> sent a code paste, see https://paste.rs/rja
12:55:22FromDiscord<sOkam!> `let buf = cast[ptr Buffer](userdata)[]` doesn't seem to be working. is the syntax incorrect, or something?
12:58:05FromDiscord<sOkam!> oh nvm, it worked. i changed some things somewhere else and the issue is gone
13:24:39FromDiscord<New> Hiho. Does anyone know a way to send an SMPP packet? :hmm:
13:24:44FromDiscord<New> (edit) removed "an"
13:34:13NimEventerNew Nimble package! nimAesCrypt - Nim file-encryption module that uses AES256-CBC to encrypt/decrypt files., see https://github.com/maxDcb/nimAesCrypt
13:59:53*progranner joined #nim
14:04:35*PMunch quit (Quit: Leaving)
14:11:37*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
14:13:59*progranner joined #nim
14:37:42*kenran quit (Remote host closed the connection)
14:38:06FromDiscord<auxym> In reply to @New "Hiho. Does anyone know": Could write bindings for https://github.com/osmocom/libsmpp34. pmunch just wrote a blog post / tutorial on binding with his futhark library, which takes care of the hard work for you.
14:43:09*fredrikhr quit (Quit: Disconnecting...)
14:45:11*lucasta joined #nim
14:58:36FromDiscord<ringabout> In reply to @Yardanico "Is it documented in": I agree => https://github.com/nim-lang/Nim/pull/21686
14:58:48FromDiscord<Yardanico> thanks :)
15:00:51FromDiscord<ringabout> no problem
15:19:28FromDiscord<Ayy Lmao> Is it possible to use `--threads:on` in a dll hosted in another program? This dll has functions in it that are called on multiple host threads, and when I turn threads on it immediately segfaults on the first function call and runs fine without them on.
15:22:42FromDiscord<sOkam!> is it safe to map `size_t` aka `csize_t` to `uint64`?
15:25:24FromDiscord<Graveflo> I think since it's platform dependent that would limit the platforms that the code will compile nicely on. Might want to add a hard check if you are okay with only targeting platforms where size_t is the same size as uint64
15:49:37*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
16:27:50*arkurious joined #nim
16:28:03FromDiscord<gogolxdong> How to map int24, int160,etc. to nim-web3 implement?
16:28:17FromDiscord<gogolxdong> (edit) "int160,etc." => "int160, uint160 etc."
16:40:47NimEventerNew post on r/nim by qtless: Happyx, web-framework written in Nim, see https://reddit.com/r/nim/comments/12qvchy/happyx_webframework_written_in_nim/
16:51:57*progranner joined #nim
17:03:47*rockcavera joined #nim
17:11:35*jmdaemon joined #nim
17:14:16FromDiscord<firasuke> so I am trying to prepend my output with the elapsed time of running of a certain function. I have a getMonoTime() before and after, and I am subtracting and getting the result which is of type Duration but I want to format it to be in form of (HH:MM:SS) elapsed time. using .format() on Duration does not work, any ideas?
17:21:54*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:22:32*progranner joined #nim
17:23:30*lucasta quit (Remote host closed the connection)
17:23:45*lucasta joined #nim
17:25:58FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4tJn
17:26:17FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4tJn" => "https://play.nim-lang.org/#ix=4tJo"
17:26:45FromDiscord<firasuke> sent a code paste, see https://play.nim-lang.org/#ix=4tJp
17:26:54FromDiscord<Arathanis> i thought you said you had a Duration
17:27:08FromDiscord<Arathanis> or is it a same-named type in monotimes?
17:27:33FromDiscord<Arathanis> looked it up, it is.
17:28:39FromDiscord<firasuke> yes, subtracting two getMonoTime() yields a duration
17:28:45FromDiscord<firasuke> (edit) "duration" => "`Duration`"
17:30:19FromDiscord<Arathanis> then good news! the Duration used in `monotimes` is a `std/times` `Duration` so you can do what i suggestd above.
17:30:28FromDiscord<Arathanis> (edit) "Duration" => "`Duration`"
17:33:30FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4tJr
17:33:51FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4tJr" => "https://play.nim-lang.org/#ix=4tJs"
17:34:02FromDiscord<Arathanis> @firasuke ^
17:35:05FromDiscord<firasuke> sent a code paste, see https://play.nim-lang.org/#ix=4tJu
17:35:26FromDiscord<Arathanis> In reply to @firasuke "thanks a lot, how": should be the same, you can use that instead.
17:35:35FromDiscord<firasuke> oh ok thanks
17:36:36FromDiscord<Arathanis> you can omit the parens too 😉
17:38:54*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:39:21*progranner joined #nim
17:42:06*progranner quit (Client Quit)
17:46:24*progranner joined #nim
17:47:43FromDiscord<firasuke> yup
17:49:57FromDiscord<Ayy Lmao> If I want to render on a different thread, do I need to create the window and all of the associated data on that thread or is there some way to accomplish it without doing that?
17:50:51FromDiscord<Arathanis> In reply to @Ayy Lmao "If I want to": im probably going to put my foot in my mouth but... since Nim doesn't share memory between threads for memory safety the render thread is going to need to own the GUI elements I think
17:51:02FromDiscord<Arathanis> someone more knowledgeable will probably come say I am wrong.
17:52:36FromDiscord<Ayy Lmao> In reply to @Arathanis "im probably going to": It is seeming like that might be the case because the compiler keeps telling me it isn't gcsafe no matter what I try.
17:52:45FromDiscord<Ayy Lmao> I am not sure how to go about having the thread own the data though.
17:53:30FromDiscord<Arathanis> In reply to @Ayy Lmao "It is seeming like": The way I would approach this is the render thread owns all the GUI elements and use channels to pass GUI update events in a pub/sub style kind of setup
17:53:57FromDiscord<Ayy Lmao> Basically I am doing a plugin, and the host can request for you to create, destroy, resize etc the GUI.
17:54:22FromDiscord<Ayy Lmao> I was thinking about going with the channel approach but I am not sure how to pipe all of the host requests to the thread in a sane way
17:55:21FromDiscord<Ayy Lmao> The GUI also needs to control parameters which need to stay in sync with another thread.
17:57:49FromDiscord<Ayy Lmao> And to top it off the window needs to be embedded inside another window, which would be on a different thread if the render thread owns the child window.
18:23:45*lucasta quit (Read error: Connection reset by peer)
18:24:02*lucasta joined #nim
18:24:25*lucasta quit (Client Quit)
18:41:41*hochata joined #nim
18:54:11FromDiscord<Ayy Lmao> Looks like I might not need to deal with this anyway because for some reason when I compile with `threads:on` I get segfaults just from interacting with pointers given by the host.
18:56:59*rockcavera quit (Remote host closed the connection)
18:58:57*rockcavera joined #nim
19:01:32FromDiscord<Dre4mer> sent a long message, see http://ix.io/4tJN
19:08:48*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
19:09:32FromDiscord<Nerve> Are there existing references to the old elements?
19:11:45FromDiscord<Nerve> Try `jsonArray = %[]`
19:11:56FromDiscord<Nerve> I don't know if that's quite the same effect but I'm curious
19:12:20FromDiscord<Yardanico> In reply to @Dre4mer "I am using std/json,": you can try doing `myjsonarray.elems.setLen(0)`
19:12:34FromDiscord<Yardanico> it will not deallocate the old memory to reuse memory, but it shouldn't lead to a memory leak
19:28:30*progranner joined #nim
19:28:42*progranner quit (Client Quit)
19:38:27FromDiscord<Ducko> is there any way to "simply" do a c-style `#include` of native libs? tried using `c2nim` and it just discarded
19:38:41FromDiscord<Yardanico> In reply to @Ducko "is there any way": not sure what you mean?
19:38:56FromDiscord<Yardanico> if you want automatic generation of Nim bindings to C headers/libraries, futhark is your best bet I guess
19:39:41FromDiscord<Ducko> I mean I have a c (header) file using native libs like `windows.h` and `elf.h`
19:40:01FromDiscord<Ducko> wanting to do the equivalent in nim but no clue how
19:40:22FromDiscord<Ducko> some things included don't have bindings (afaik) so
19:50:53FromDiscord<Elegantbeef> Look at winim
19:54:51FromDiscord<Dre4mer> In reply to @Nerve "Are there existing references": No, basically the same variable of type jsonNode gets new values and it gets added to the above array
19:58:27FromDiscord<Dre4mer> In reply to @Nerve "Try `jsonArray = %*[]`": Thanks, this works. And now I am able to see it in the docs page!! Not as an empty array, but should be enough to give that idea. I feel so silly now 🤐
19:59:18FromDiscord<Dre4mer> In reply to @Nerve "I don't know if": Yeah, looks like the same, creating a new object and assigning it back. I'll try w/ it though.
20:00:00FromDiscord<Dre4mer> In reply to @Yardanico "it will not deallocate": I see, let me try your suggestion.
20:08:39FromDiscord<Dre4mer> @Yardanico @Nerve Trying out your suggestions, will take a few hours to monitor
20:08:48FromDiscord<Yardanico> are you using orc?
20:08:57FromDiscord<Yardanico> i mean, what Nim version and are you using aspecific gc
20:09:27FromDiscord<Dre4mer> (edit) "monitor" => "monitor. Thank you both for the help 🙂"
20:11:42FromDiscord<Dre4mer> sent a long message, see http://ix.io/4tK6
20:12:03FromDiscord<Yardanico> In reply to @Dre4mer "Nim Compiler Version 1.7.3": you seem to be using a very weird version
20:12:12FromDiscord<Yardanico> it's a devel version that's newer than 1.6.12 but still much older than current devel
20:12:19FromDiscord<Yardanico> update to current devel
20:13:55FromDiscord<Dre4mer> In reply to @Yardanico "it's a devel version": Interesting, haven't been looking at the versions, I have been more focused on learning. I will update it and use after the current runs and monitoring is over. Basically this is arm64 (on AWS graviton ec2)
20:15:16FromDiscord<Yardanico> Current nim devel will use orc by default
20:15:19FromDiscord<Yardanico> (edit) "will use" => "uses"
20:15:48FromDiscord<Dre4mer> And which one is used by my version? Just curious to understand
20:16:19FromDiscord<Elegantbeef> will note\
20:16:19FromDiscord<Elegantbeef> @sOkam! will not you can do `for x in myPtr.toOpenArray(0, len - 1): ...`
20:31:13*progranner joined #nim
20:37:36*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
20:49:04*hochata quit (Ping timeout: 248 seconds)
21:50:10FromDiscord<Arathanis> are there docs for all the GC options and their implications?
21:51:26FromDiscord<Elegantbeef> https://nim-lang.org/docs/mm.html
21:53:31FromDiscord<Arathanis> Is orc, the recommended, also the default?
21:53:52FromDiscord<Elegantbeef> In devel it is the default
21:53:59FromDiscord<Elegantbeef> Prior to that it was refc
21:54:12FromDiscord<Arathanis> so im guessing its still refc in 1.6.12?
21:54:19FromDiscord<Elegantbeef> Yes
21:54:23FromDiscord<Arathanis> kk thn
21:54:25FromDiscord<Arathanis> (edit) "thn" => "thnx"
22:00:53*advesperacit quit ()
22:07:11*pharonix71 quit (Remote host closed the connection)
22:08:05FromDiscord<Ayy Lmao> What are the implications of using `threads:on` in a dll? Simply turning it on seems to cause segfaults in weird places in my case.
22:08:50FromDiscord<Elegantbeef> Did you call `NimMain` and are you actually using threads?
22:09:47*jmdaemon quit (Ping timeout: 246 seconds)
22:10:21FromDiscord<Ayy Lmao> In reply to @Elegantbeef "Did you call `NimMain`": I'm pretty sure I called NimMain but the entry point is weird so I'm not certain. The code runs fine without `threads:on` and with it on I'm getting a segfault for interacting with a simple pointer given to me by the host.
22:10:27*Notxor quit (Remote host closed the connection)
22:10:30FromDiscord<Ayy Lmao> I want to use threads but I am not actually using them yet.
22:12:15FromDiscord<Elegantbeef> Well if you are not using threads presently sounds like a logic bug
22:13:54FromDiscord<Ayy Lmao> Is there any reason why simply turning threads on would cause segfaults when the code runs fine without it? Like what exactly does turning threads on do if you don't actually use any threads?
22:14:16FromDiscord<Elegantbeef> Uses a threadsafe allocator and that's pretty much it
22:15:12FromDiscord<Ayy Lmao> Well I am interacting with two different host threads, maybe that has something to do with it?
22:15:33FromDiscord<Elegantbeef> Hard to really say, if you can use valgrind that'd be the best
22:17:05NimEventerNew thread by FluxCapacitor: Type mismatch with echo and trouble accessing Type fields, see https://forum.nim-lang.org/t/10111
22:20:41FromDiscord<Ayy Lmao> I'll have to look into it, I've never used it before. I'm using lldb but it just tells me there's an access violation.