<< 11-04-2023 >>

00:00:22FromDiscord<Phil> Well yeah, that's compile-time polymorphism, that has to work 😛
00:01:08FromDiscord<Elegantbeef> hey not everyone knows `C` can dispatch as `A` 😄
00:01:22FromDiscord<Phil> Fair, though I just realized something in my way of thinking
00:01:48FromDiscord<Phil> For some reason I inherently assumed that runtime polymorphism is more complicated than compiletime polymorphism (as in, on the compiler-side)
00:01:49*Lord_Nightmare joined #nim
00:01:52FromDiscord<Phil> Is that actually a true assumption?
00:02:03FromDiscord<Elegantbeef> Really though Nim should emit compile time errors for any upcasted stack types
00:02:42FromDiscord<Elegantbeef> Runtime polymorphism is a bit more complicated cause you need RTTI and dynamic dispatch
00:02:58FromDiscord<Elegantbeef> Which means either a VTable or if statements like Nim presently does for dynamic dispatch
00:05:53FromDiscord<Elegantbeef> Though RTTI can just be an integer, it's not that much more complicated
00:15:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4t9M
01:01:44*derpydoo joined #nim
01:04:20*nanxiao joined #nim
01:55:36FromDiscord<Dudugz> Are there any clear differences between method and proc? I mean to me it looks like they were undecided on which keyword to use and put both
01:56:10FromDiscord<Elegantbeef> method is for dynamic dispatch
01:56:11FromDiscord<Elegantbeef> proc is for static dispatch
01:56:27FromDiscord<Dudugz> Hm
02:37:57*Jjp137 quit (Ping timeout: 250 seconds)
02:41:08*Jjp137 joined #nim
02:48:24*nanxiao quit (Quit: Client closed)
02:55:35FromDiscord<Gumbercules> @jmgomez - I was doing more reading about this whole virtual function thing and how a compiler lays out a vtable isn't part of the C++ specification - so compilers are free to do it as they please - or even not use a virtual table if they wish
02:56:08FromDiscord<Gumbercules> so I guess these Zig bindings for Jolt only work with mingw
02:59:28*nanxiao joined #nim
03:10:12*lucasta quit (Quit: Leaving)
03:12:06FromDiscord<Elegantbeef> Such an awful thing to leave down to compilers
03:16:25FromDiscord<Gumbercules> yeah - it's quite annoying and msvc does all sorts of fuckery in their approach so I'm just going to use another approach. Honestly I'm not sure why the Zig people are going with this approach - it seems like it cold break rather easily, but whatever works I suppose.
03:32:13FromDiscord<michaelb.eth> In reply to @Elegantbeef "method is for dynamic": sometimes I wish/dream that Nim could support a full blown equivalent of Clojure’s multimethods. Sure, there’d be additional runtime overhead (when using that facility) but in some cases seems like it could be worth it just for the expressiveness alone↵↵https://clojuredocs.org/clojure.core/defmulti
03:32:26FromDiscord<Elegantbeef> Nim does have multimethods
03:32:33FromDiscord<Elegantbeef> They're deprecated
03:32:35FromDiscord<Elegantbeef> But they're there
03:32:50FromDiscord<michaelb.eth> Sure, I looked into that
03:34:11FromDiscord<michaelb.eth> Not quite the same as multimethod , but I appreciate that there were some real issues
03:34:44FromDiscord<michaelb.eth> (edit) "Not quite the same as ... multimethod" added "Clojure’s"
03:34:51FromDiscord<Elegantbeef> Well it doesnt really explain what it does here 😄
03:35:06FromDiscord<michaelb.eth> (edit) "multimethod ," => "multimethod,"
03:36:09FromDiscord<michaelb.eth> the page I linked?
03:36:14FromDiscord<Elegantbeef> Yea
03:36:16FromDiscord<Elegantbeef> I cannot read the code
03:36:27FromDiscord<michaelb.eth> never had a scheme/lisp bender?
03:37:00FromDiscord<Elegantbeef> Of course not i like my sanity
03:37:19FromDiscord<michaelb.eth> yeah, for sure, it is probably for the best
03:38:12FromDiscord<Elegantbeef> From cursory reading this seems to use static values to dispatch
03:38:36FromDiscord<michaelb.eth> will try to translate... give me a min
03:46:06FromDiscord<Dudugz> In reply to @michaelb.eth "sometimes I wish/dream that": 🤡 what black magic is this? I didn't understand anything on this page
03:47:27FromDiscord<michaelb.eth> In reply to @Dudugz "🤡 what black magic": scheme is fun, lisp is fun, racket lang takes that "fun" to more of a complete brain-masher level
04:06:11*onetwo quit (Ping timeout: 246 seconds)
04:14:43FromDiscord<michaelb.eth> sent a long message, see http://ix.io/4ta7
04:22:46*nanxiao quit (Quit: Client closed)
04:27:24FromDiscord<michaelb.eth> fwiw, Rich Hickey, the creator of Clojure described this facility as polymorphism à la carte, which is a fairly apt description. But... Clojure is definitely not a statically typed language, so maybe it's not really possible to translate it to a language that is statically typed.
04:27:37FromDiscord<michaelb.eth> (edit) "fwiw, Rich Hickey, the creator of Clojure ... described" added "has"
04:27:55FromDiscord<Elegantbeef> No clue i still have yet given what you wrote a solid read
04:48:06FromDiscord<ringabout> I'd like to simply drop i386 CI since I don't see tests for i386 in other language (Crystal does building tests while perl does docker tests). It is so damn hard => https://github.com/nim-lang/Nim/pull/21637 is a potential way but it is probably not correct.
05:03:02*nanxiao joined #nim
05:03:56madpropstrying to find out how to use this to invert colors in the output
05:03:57madpropshttps://nim-lang.org/docs/terminal.html
05:04:02madpropslike to highlight some parts of a line
05:06:02FromDiscord<Rika> styleReverse
05:06:18madpropsahh
05:06:19madpropsthanks
05:06:36FromDiscord<Rika> I think that’s the one at least
05:08:39madpropsindeed it is
05:08:48madpropsnow i have to do the code to highlight specific parts
05:30:12*rockcavera quit (Remote host closed the connection)
05:35:24madpropshmm chatgpt thinks "re" has a "compile" function
05:36:52madpropslet pattern = re.compile(r"brown", re.IGNORECASE)
05:39:58madpropsalso got wrong about replacing with a callback
05:46:19FromDiscord<Rika> Because it probably thinks about python
05:47:13madpropsseeing some example using `=>` in the forum
05:47:20madpropsbut that doesn't seem to be an operator
05:47:28FromDiscord<Rika> It is
05:47:38FromDiscord<Rika> Imported in sugar module
05:47:48madpropsoh
06:01:43madpropsok done. now my string finder can highlight https://i.imgur.com/VGWaZn3.jpg
06:02:42madpropsexcept if the substring is at the cropped end
06:02:46madpropssince i cut long lines
06:02:54madpropsmaybe i shouldn't
06:05:35FromDiscord<Rika> You can also alternatively set both a background and foreground colour for the section
06:06:11madpropsnot sure what you mean
06:08:58madpropshttps://i.imgur.com/ywnrJ3i.jpg
06:09:31madpropslooks a bit ugly without cutting the lines but it's better to not hide stuff
06:10:09madpropsalso has a -h flag to disable highlighting
06:15:22*kenran joined #nim
06:22:55*derpydoo quit (Ping timeout: 268 seconds)
06:27:08FromDiscord<Elegantbeef> @michaelb.eth see i cannot look at fancy type stuff like this, it just drives me to write toys
06:27:09FromDiscord<Elegantbeef> https://hatebin.com/ikqtpcwgnu
06:28:03FromDiscord<Elegantbeef> It's 100% specialised for the factorial example, but the point still stands. The dynamic dispatch in many cases is mostly just a `isConvertible` to some overload that exists
06:29:24FromDiscord<Elegantbeef> I do imagine one can emit this type of logic based off of whether `when compiles(isConvertible(param, paramType))`
06:29:33FromDiscord<Elegantbeef> So it wouldnt just be value based like i wrote here
06:31:38FromDiscord<Elegantbeef> Expanding this out to a proper implementation would be quite interesting, but I am not going to do it
06:34:30*nanxiao quit (Quit: Client closed)
06:39:55Amun-Rahow'd you iterate all the function type vars in a module?
06:40:59Amun-RaI mean I plan to write a macro but I don't really know how to get all the vars
06:41:33FromDiscord<Elegantbeef> There is no way of querying all symbols in a module
06:42:53Amun-Raouch, thanks
06:43:05FromDiscord<Elegantbeef> Generally the way to do what you want is to write a macro that you use as a pragma which stores the symbol into a cachetable
06:43:52Amun-RaI have all those vars in an object and I thought I could get rid of it
06:44:30FromDiscord<huantian> vars?
06:44:37Amun-Ravariables
06:44:49FromDiscord<Elegantbeef> We're familiar with the term
06:44:53FromDiscord<Elegantbeef> We're uncertain what you mean
06:45:05FromDiscord<huantian> lol i didn't mean like that, I wasn't sure what you mean by a var in an object
06:46:02Amun-Raright, sorry ;)
06:47:04Amun-RaI have a bunch of cdecl variables and I wanted to assign their values automatically by their names
06:48:06Amun-Rafor example: var SDL_Init*: proc (x: uint32) {.cdecl.} and init all of them after successful dlsym
06:48:29Amun-Radlopen*
06:49:32FromDiscord<Elegantbeef> Yea best to make a macro so you can wrap the var decls and it generates a proc you can call to init them
06:49:39FromDiscord<Elegantbeef> Or adds them to table
06:50:11Amun-Rahmm
06:52:55FromDiscord<Elegantbeef> I could give you the nimscripter reference that sorta works this way
06:53:02FromDiscord<Elegantbeef> but it's quite complicated
06:53:23*PMunch joined #nim
06:54:14*lucasta joined #nim
06:54:26*nanxiao joined #nim
06:55:28Amun-RaI could give it a try
06:56:33FromDiscord<Elegantbeef> https://github.com/beef331/nimscripter/blob/master/src/nimscripter/expose.nim#L177-L182 this is the entry for adding a procedure to the table named `moduleName`
06:56:50Amun-Rathanks
06:56:53FromDiscord<Elegantbeef> it calls `addToCache` with the symbol
06:57:19FromDiscord<Elegantbeef> you can go through there
06:57:37FromDiscord<Elegantbeef> then `implNimscriptModule` is used to 'finalize' a module
06:58:05FromDiscord<Elegantbeef> It emits a populated version of https://github.com/beef331/nimscripter/blob/master/src/nimscripter/vmaddins.nim#L8-L11
06:58:13FromDiscord<Elegantbeef> Hopefully this helps and doesnt just cause massive confusion
06:59:58*onetwo joined #nim
07:02:02Amun-RaI have something similar, procs stored in an object, but my solution is not that universal (https://github.com/amnr/dynlibutils); I thought I could get rid of storing them in an object
07:07:48FromDiscord<Phil> Oh hey, the nim image project is now part of dockers open source program, so even if they sunset the legacy tiers again we'll still be good
07:08:19FromDiscord<huantian> What did happen with the docker open source thing
07:08:36FromDiscord<huantian> I only heard tbe complains not the resolution
07:08:37FromDiscord<Phil> They backtracked immediately after literally nobody knows if their images would still work come their deadline
07:08:46FromDiscord<Phil> (edit) "knows" => "knew anymore"
07:08:53FromDiscord<huantian> Ah
07:09:09PMunchBacktracked in what way?
07:09:31FromDiscord<Phil> With the kind of negative press it generated they basically set "We're no longer sunsetting the program, we didn't want to alarm anyone" etc. etc.
07:09:42PMunchRight..
07:11:38*advesperacit joined #nim
07:41:15*Notxor joined #nim
07:42:21PMunchHmm, is there a way to assign a range in an enum?
07:42:38PMunchI want to have some values tracked and defined, and others ignored
07:43:06PMunchCurrently parsing as an enum fails with a RangeDefect, but I want it to always pass but just have an "Unknown" value
07:50:33FromDiscord<Dudugz> I think you can use E.low and E.high to check the range of an enum
07:51:55FromDiscord<Dudugz> https://nim-by-example.github.io/types/enums/
07:56:24FromDiscord<Dudugz> sent a code paste, see https://paste.rs/zPG
07:58:47FromDiscord<Elegantbeef> Pmunch the playground needs rebooted
07:58:52FromDiscord<Elegantbeef> Also what about something like https://hatebin.com/mdviojhhaj
07:59:12FromDiscord<Elegantbeef> Not the most ideal for large ranges, but for smaller ones it's pretty nice
07:59:32FromDiscord<Elegantbeef> Alternatively you make a massive case statement inside `classify`
08:00:32PMunchCurrently I went with a try/catch for the RangeDefect and just set it to my bad range thing
08:00:47FromDiscord<Elegantbeef> How awful
08:00:59FromDiscord<Elegantbeef> Pmunch wants slow code
08:00:59PMunch@Elegantbeef, I like your solution, but I need the enum values to have specific values and 0 is already taken
08:01:12FromDiscord<Elegantbeef> Second LUT
08:01:49FromDiscord<jmgomez> In reply to @Gumbercules "<@726017160115126333> - I was": yeah, I saw that somewhere too, so it plus ergonomics was the reason behind me emiting code rather than trying to match the layout. Although I think most compilers do the same in practical terms, but didnt want to find out 😅
08:02:05FromDiscord<Elegantbeef> You also could use `-1`
08:04:02PMunchCrap, playground disk is full again..
08:04:29PMunch@Elegantbeef, sure but then I need to pre-populate the LUT and not let the default 0 value do the work :P
08:04:39FromDiscord<Elegantbeef> https://hatebin.com/arrjkrtnzh take two
08:04:42PMunchHow slow are exceptions by the way?
08:05:06PMunchLike how much would could you put into not throwing one before it becomes slower
08:05:10FromDiscord<Elegantbeef> Slow on the bad path fast on the good path
08:05:36FromDiscord<Elegantbeef> But you're not supposed to catch defects and if someone compiles with `--panics:on` your code will not work
08:06:33PMunchFair enough
08:07:00PMunchI mean this is just my tiny little keypass manager script
08:07:10PMunchSo I'm the only one compiling it
08:07:17PMunchOh wait, this is actually libkeepass
08:07:22PMunchI guess someone else could use that
08:07:44PMunchBut the encryption library it uses doesn't even compile properly with -d:release so I'm not sure..
08:08:11FromDiscord<Elegantbeef> Well then if that's the case you do you
08:08:12FromDiscord<Elegantbeef> 😄
08:09:50PMunchUgh, the playground keeps running out of space
08:09:55PMunchStupid docker..
08:16:23FromDiscord<Phil> Is the playground image leaking?
08:16:27FromDiscord<Phil> (edit) "leaking?" => "leaking memory?"
08:16:31PMunchAll docker images are leaking..
08:16:40*junaid_ joined #nim
08:16:56FromDiscord<Phil> Yes, but is it leaking memory specifically :-P?
08:16:57FromDiscord<Dudugz> In reply to @Elegantbeef "But you're not supposed": Is there any way to check if a port on a machine is available other than using the error generated when trying to listen to a socket with the same port?
08:17:06FromDiscord<Phil> If so, could be useful to just have an auto-reboot once every 12h or so
08:17:21PMunchEssentially there is a some stuff left in /var/lib/docker/overlay2 for every container you spin up
08:17:48*junaid_ quit (Remote host closed the connection)
08:17:52PMunchAnd since the playground runs a new container every time someone runs code it builds up
08:18:00PMunchWhich slowly but surely fills the disk up
08:18:11PMunchAnd in time grinds the entire system to a halt
08:18:20FromDiscord<Phil> Is that something you can deal with via a cronjob or via docker prune ?
08:18:32FromDiscord<Phil> Like, running docker-prune regularly or sth
08:25:08PMunchNope
08:25:22PMunchDocker prune doesn't clear out those files
08:27:51PMunchIf someone wants a fun little GUI project I would very much like a tool like baobab but which read the output of `du`
08:28:29PMunchSo I could run du on a server and pipe it into a file, then download that file to my machine and dig through it there
08:28:52FromDiscord<Rika> ncdu
08:29:00FromDiscord<Rika> Curses like version of du
08:30:46*nanxiao quit (Quit: Client closed)
08:47:52PMunchFair enough
08:53:24PMunchHmm, I might have to ditch some of the versions the playground supports
08:56:36PMunchOkay, I ditched all the pre-1.2 versions
09:09:33PMunchHmm, fun.. The Keepass database format has updated, and it changes so much stuff that I need to rewrite libkeepass..
09:09:57FromDiscord<Rika> What?
09:14:43PMunchWhat do you mean "what?"?
09:20:16FromDiscord<Rika> Why would that not be updated alongside the format?
09:21:22PMunchBecause I'm the one who wrote the package?
09:21:29PMunchThis is libkeepass-nim
09:22:25PMunchAFAIK there is no C version available of libkeepass, so I wrote my own in Nim
09:31:55*lucasta quit (Remote host closed the connection)
09:35:16*lucasta joined #nim
09:51:54NimEventerNew thread by seves: How the acyclic pragma works, see https://forum.nim-lang.org/t/10088
10:49:15*lucasta quit (Remote host closed the connection)
10:49:40*lucasta joined #nim
11:03:11*kenran` joined #nim
11:04:31*kenran quit (Ping timeout: 240 seconds)
11:23:17PMunchHmm, so upgrading the playground to the latest Ubuntu LTS means it doesn't have libssl1.0 any longer
11:23:28PMunchSo now the playground doesn't work, and neither does choosenim
11:25:03FromDiscord<jmgomez> where the compiler generates the body of a type? I can see the code for the forward declaration but cant find the whole thing
11:36:56*def- quit (Quit: -)
11:39:43*xxgg joined #nim
11:40:07PMunchOkay, playground is back up now
11:43:05FromDiscord<demotomohiro> !eval echo "Thank you, PMunch!"
11:43:11NimBotThank you, PMunch!
11:44:17FromDiscord<Entikan> @planetis whatever you did works, thank you so much! <3<3<<3<3
11:49:50PMunchAlso cleared out quite a bit of space so it should hopefully be up for a bit longer until further maintenance is required
11:53:11*junaid_ joined #nim
11:55:55*junaid_ quit (Remote host closed the connection)
11:57:59*def- joined #nim
12:40:28*kenran` is now known as kenran
12:44:15*xxgg quit (Quit: Client closed)
13:11:31*kenran quit (Ping timeout: 276 seconds)
13:16:40*rockcavera joined #nim
13:18:11FromDiscord<Gumbercules> In reply to @jmgomez "yeah, I saw that": yeah :/ I'm using the C backend for my project and binding to a C API that wraps the C++ API so emiting won't work for me
13:41:06FromDiscord<jmgomez> In reply to @Gumbercules "yeah :/ I'm using": ohh, that definitely complicate things. I assume you cant just change it, right?
13:49:19*PMunch quit (Remote host closed the connection)
13:49:33*PMunch joined #nim
13:51:34*PMunch_ joined #nim
13:51:50FromDiscord<Gumbercules> The backend or the bindings? I can change the C API but it's been a pain to figure out the issues with the existing one. I found another set of bindings which seem to compile and work with msvc so I'm working on wrapping those now. What a pain though...
13:53:55*rockcavera quit (Remote host closed the connection)
13:54:07FromDiscord<jmgomez> The backend, most C libraries should work with Cpp also, right?
13:55:04*PMunch quit (Ping timeout: 276 seconds)
13:55:42*om3ga quit (Ping timeout: 250 seconds)
13:57:55*progranner joined #nim
14:01:46*progranner quit (Client Quit)
14:04:44*kenran joined #nim
14:07:13*om3ga joined #nim
14:07:30*PMunch_ quit (Quit: Leaving)
14:08:36*progranner joined #nim
14:33:09*lucasta quit (Quit: Leaving)
15:08:06FromDiscord<Bloss> rmissions
15:17:47FromDiscord<Gumbercules> probably - but it's not worth switching to me
15:18:08FromDiscord<sOkam!> is there any way to access data from files in nim? like `Stats` for unix, but preferably platform agnostic↵im specifically looking for a way to get the timestamp of a file
15:18:23FromDiscord<Gumbercules> too many downsides
15:22:30FromDiscord<sOkam!> oh, its not timestamp, its modification time, and its in the std/os module. nvm
15:23:13FromDiscord<jmgomez> comp speed?
15:29:49FromDiscord<Gumbercules> that - plus I export all of my APIs so that someone could write a plugin in any language and use the framework
15:30:11FromDiscord<Gumbercules> also, C++ has the potential to break my hot code reloading - hot reloading C++ is more complicated than C
15:34:34FromDiscord<jmgomez> In reply to @Gumbercules "that - plus I": gotcha, but just so you know I do the basic interop with UE via C (not cpp) FFI and didnt experience any issues lang specific when hot reloading DLLs (it's just Nim)
15:35:06FromDiscord<jmgomez> the comp speed if you use something like tcc makes sense
15:35:31FromDiscord<jmgomez> and less convoluted so I understand why you want to be in C
16:11:11*arkurious joined #nim
16:19:27*derpydoo joined #nim
16:22:51*ismustachio quit (Ping timeout: 255 seconds)
16:27:24*tk_ joined #nim
16:29:15*tk quit (Ping timeout: 265 seconds)
16:29:26*tk_ is now known as tk
16:37:27*ismustachio joined #nim
16:51:49*PMunch joined #nim
16:57:56*kenran quit (Remote host closed the connection)
17:22:33FromDiscord<Prestige> I have a json file I'm parsing into a Table when my program starts up, and want to use the keys of the table to generate routes via Jester. Is there a way I could do this so I could have a `get` block per key in the table?↵Looks something like this: https://play.nim-lang.org/#ix=4tcD
17:33:21FromDiscord<System64 ~ Flandre Scarlet> https://youtu.be/gutR_LNoZw0↵↵So↵Nim ftw!
17:38:14FromDiscord<Yardanico> In reply to @System64 "https://youtu.be/gutR_LNoZw0 So Nim": i think this is more for #offtopic , but it's fine since you already posted it here
17:38:28FromDiscord<Yardanico> just please remember to post something like this to #offtopic next time, since those topics can lead to a lot of discussion, sometimes even heated
17:38:42FromDiscord<Gumbercules> We already had a long ass discussion about it yesterday in there
17:39:15FromDiscord<Gumbercules> Well - not about that specific video but the subject matter the video was covering
17:40:55FromDiscord<System64 ~ Flandre Scarlet> In reply to @Yardanico "i think this is": Ah alright, sorry
17:41:11FromDiscord<System64 ~ Flandre Scarlet> In reply to @Gumbercules "Well - not about": What do you think about what happened?
17:41:32FromDiscord<System64 ~ Flandre Scarlet> We can go in #offtopic if you want
17:41:36FromDiscord<Phil> Off to offtopppiiiiiiiic
17:52:34*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:53:00*progranner joined #nim
17:59:31*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
18:00:14*progranner joined #nim
18:15:31*kenran joined #nim
18:16:22PMunchHmm, so with variant objects the value will always be stored at the same location, same as a C union, right?
18:17:11PMunchIs there a general way to get the address of this value, for stuff like streams.readData
18:18:23*rockcavera joined #nim
19:30:11*dfdf joined #nim
19:31:07NimEventerNew thread by kcvinu: Nimforms - A simple GUI library for Windows, see https://forum.nim-lang.org/t/10090
19:31:30*dfdf quit (Remote host closed the connection)
19:33:20PMunchHmm, is there a way to convert an array of bytes to a string directly?
19:33:45PMunchLike I have an array[32, byte] which I want to turn into a 32 character long string with those bytes
19:39:36adigitoleoJust coming back after a while, I updated unit tests for a Nim thing I wrote but now nimble test is stalling CI because it can't find packages.json and seems to be waiting for y/N prompt. Is there a --confirm flag or something I can use in this case?
19:45:03PMunchYes
19:46:30PMunchTry running `nimble --help` and you should be able to find it
19:50:37adigitoleoah found it, -y/--accept, I need more sleep haha
19:53:38*lucasta joined #nim
19:53:41*kenran quit (Remote host closed the connection)
19:56:42FromDiscord<guttural666> is there an equivalent of reserve in C++ for a vector in Nim for sequences? I know setLen, but that actually grows the seq and initializes new entries etc. so add is not appropriate anymore
19:58:39FromDiscord<guttural666> (to avoid reallocations if I know beforehand I want to add 500k elements etc.)
20:05:09*tiorock joined #nim
20:05:09*tiorock quit (Changing host)
20:05:09*tiorock joined #nim
20:05:09*rockcavera quit (Killed (calcium.libera.chat (Nickname regained by services)))
20:05:09*tiorock is now known as rockcavera
20:06:08*rockcavera quit (Remote host closed the connection)
20:09:02*rockcavera joined #nim
20:19:50FromDiscord<Elegantbeef> `newSeqOfCap`
20:20:09FromDiscord<Elegantbeef> `mySeq.setLen(newSize); mySeq.setLen(startSize)`
20:20:25FromDiscord<Elegantbeef> Though using `add` is still slower than just indexing
20:42:58*rockcavera quit (Remote host closed the connection)
20:43:13FromDiscord<michaelb.eth> In reply to @PMunch "Like I have an": see stew/byteutils `string.fromBytes`↵https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L256
20:44:18FromDiscord<Daniel Belmes> sent a code paste, see https://play.nim-lang.org/#ix=
20:45:39FromDiscord<Daniel Belmes> I might just leave it out because it's has more usage in writing a C app than writing a Nim app. But I'm trying to be a completionist.
20:47:34NimEventerNew post on r/nim by noobpotato: Mixed language (Nim &amp; C/C++) example projects?, see https://reddit.com/r/nim/comments/12ix2li/mixed_language_nim_cc_example_projects/
20:49:28*Batzy_ joined #nim
20:52:16*Batzy quit (Ping timeout: 248 seconds)
20:57:51*Batzy joined #nim
20:59:02*rockcavera joined #nim
20:59:08*rockcavera quit (Remote host closed the connection)
21:01:05*Batzy_ quit (Ping timeout: 260 seconds)
21:01:53*PMunch quit (Quit: leaving)
21:02:28*lucasta quit (Remote host closed the connection)
21:03:58*rockcavera joined #nim
21:08:04FromDiscord<guttural666> In reply to @Elegantbeef "`newSeqOfCap`": I think this will truly just make memory room for a seq of cap x right? as in len vs. cap
21:09:09*rockcavera quit (Remote host closed the connection)
21:09:13FromDiscord<Elegantbeef> If you want to grow a sequence use the `setLen` up then back down
21:09:28*rockcavera joined #nim
21:09:28*rockcavera quit (Changing host)
21:09:28*rockcavera joined #nim
21:09:34FromDiscord<guttural666> In reply to @Elegantbeef "Though using `add` is": will it though? if the cap allows for that add? shouldn't cause a realloc and just recast the underlying array or something like that?
21:10:14FromDiscord<Elegantbeef> `newSeqOfCap` allocates a sequence of an exact size
21:10:16FromDiscord<guttural666> In reply to @Elegantbeef "If you want to": bit of a pity that there is no reserve equiv though, I will have to change code for this
21:10:21FromDiscord<Elegantbeef> `add` will place values from 0 to cap and then grow when required
21:10:26FromDiscord<Elegantbeef> I mean
21:11:06FromDiscord<guttural666> In reply to @Elegantbeef "`newSeqOfCap` allocates a sequence": yeah, but a lot of the time you have a given database or something like that and you just want to tell it to realloc once, because you say hey, there are 100k items coming do a realloc once and you'll be fine
21:11:16FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tdw
21:12:29FromDiscord<Dudugz> How fast is Nim's FFI? I mean, most libraries are just static library bindings
21:12:38*advesperacit quit ()
21:12:40FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#ix=4tdx
21:13:06FromDiscord<Elegantbeef> A PR could be added to system
21:13:16FromDiscord<Elegantbeef> You can literally copy the code i wrote
21:14:11FromDiscord<Elegantbeef> Yea reserve is just the same as setlen and reset it
21:14:45FromDiscord<Elegantbeef> If you do not have an existent seq though the allocation of a cap is reserve
21:17:12FromDiscord<guttural666> In reply to @Elegantbeef "If you do not": yes
21:17:44FromDiscord<guttural666> (edit) "yes" => "no, because you will have a bunch of default initialized stuff, not memory available"
21:17:57FromDiscord<Elegantbeef> What?
21:19:05FromDiscord<Elegantbeef> !eval echo newSeqOfCap[int](10)
21:19:07FromDiscord<guttural666> setLen default initializes x amounts of type in memory making add not usable for specific use cases, reserve just allocates memory on the heap
21:19:07FromDiscord<Elegantbeef> Fuuuck
21:19:11NimBot@[]
21:19:44FromDiscord<Elegantbeef> Nim 0 inits memory allocations
21:19:44FromDiscord<Elegantbeef> Regardless
21:21:12*om3ga quit (Ping timeout: 255 seconds)
21:21:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tdz
21:21:38FromDiscord<Elegantbeef> Whoops `0..<7`
21:23:08FromDiscord<guttural666> won't add add 7 elements to the seq making it of len = 17? pretty sure that is what's happening
21:23:17FromDiscord<Elegantbeef> Nope
21:23:23FromDiscord<guttural666> ohhhh
21:23:29FromDiscord<guttural666> will try that out
21:23:44FromDiscord<Elegantbeef> Cause i reset the `setLen` after
21:23:46FromDiscord<Elegantbeef> setlen does not shrink the sequence
21:23:47FromDiscord<Elegantbeef> It only changes the length, not the capacity
21:24:41FromDiscord<Elegantbeef> If you do not have an allocate sequence the same allies to `newSeqOfCap`
21:24:58*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
21:25:00FromDiscord<Elegantbeef> It reserves the amount you specify then future adds will not cause it to grow until it grows over `cap`
21:25:08FromDiscord<Elegantbeef> `newSeq[T]` is the on that length is the size given
21:25:57FromDiscord<Elegantbeef> https://github.com/nim-lang/RFCs/issues/97 is an rfc
21:26:13FromDiscord<guttural666> ohh, that is interesting, so I misunderstood the setLen
21:26:36FromDiscord<guttural666> so it's basically doing all in one, so add will actually still work
21:26:53FromDiscord<Elegantbeef> The only way to deallocate memory from a sequence in Nim is to allocate to a new sequence
21:27:21FromDiscord<Elegantbeef> With that capacity RFC perhaps there'd be another way, but presently that's it
21:27:37FromDiscord<Elegantbeef> Sequence's `setLen` keeps the memory so you can reuse allocations
21:31:14FromDiscord<guttural666> nah, that is not correct, add will actually add another elem
21:31:52FromDiscord<guttural666> https://media.discordapp.net/attachments/371759389889003532/1095461237938204732/image.png
21:32:19FromDiscord<guttural666> this will give me 123..0..1 with 11 elems
21:32:19FromDiscord<Elegantbeef> Reread my reserve procedure
21:32:34FromDiscord<Elegantbeef> I set len to 10 then back to original
21:32:39FromDiscord<Elegantbeef> Just use the reserve procedure
21:32:59FromDiscord<guttural666> yeah okay
21:39:35FromDiscord<guttural666> will resetting a seq from 100k back to 0 actually release the memory back to the system?
21:41:02FromDiscord<Elegantbeef> Does anyone read what i type?
21:41:13FromDiscord<Elegantbeef> > The only way to deallocate memory from a sequence in Nim is to allocate to a new sequence
21:43:03FromDiscord<jmgomez> Hey Beef, by any chance do you have an answer to my question on internals?
21:43:29FromDiscord<guttural666> In reply to @Elegantbeef "> The only way": sorry yes
21:50:20FromDiscord<guttural666> In reply to @Elegantbeef "Does anyone read what": this is curious though, so it still holds on to 100k memory space even if you reduce the len back to 0? you would have to assign a new seq to that var
21:50:43FromDiscord<Elegantbeef> Yes
21:50:45FromDiscord<guttural666> (edit) "In reply to @Elegantbeef "Does anyone read what": this is curious though, so it still holds on to 100k memory space even if you reduce the len back to 0? you would have to assign a new seq to that var ... " added "to allow it to go back to system / heap memory"
21:50:45FromDiscord<Elegantbeef> It's for reuse
21:50:56FromDiscord<Elegantbeef> Nope jm i do not touch gen code
21:51:14FromDiscord<Elegantbeef> Generally speaking when you do `setLen(0)` you want to reuse the collection without allocating
21:51:55FromDiscord<guttural666> In reply to @Elegantbeef "Generally speaking when you": okay, very interesting
21:52:06FromDiscord<guttural666> thanks for the explanation
21:54:26FromDiscord<guttural666> so this should free the memory previously allocated https://media.discordapp.net/attachments/371759389889003532/1095466917927596052/image.png
21:57:52*Notxor quit (Remote host closed the connection)
22:09:49FromDiscord<Elegantbeef> Yep
22:10:43FromDiscord<Elegantbeef> Though `bands` is a local variable so it'll get GC'd
22:11:31FromDiscord<guttural666> In reply to @Elegantbeef "Though `bands` is a": doesn't my assignment overwrite that? or tell the GC that it's okay to reclaim that memory?
22:11:53FromDiscord<Elegantbeef> It likely gets it to deallocate directly there
22:12:07FromDiscord<Elegantbeef> But there is hardly a difference between `= @[]` and letting the memory management handle it
22:14:31FromDiscord<guttural666> probably, but it is the right thing to do I guess, don't need that local anymore as soon as it is safe on the DB
22:15:02FromDiscord<guttural666> don't want to use any more memory that I need at any time
22:15:03FromDiscord<Elegantbeef> The right thing to do 9/10 times is let Nim manage your memory 😛
22:15:10FromDiscord<guttural666> yeeeeah 😄
22:15:21FromDiscord<Elegantbeef> What's the full scope and what mm are you using?
22:15:33FromDiscord<guttural666> mm?
22:16:04FromDiscord<Elegantbeef> memory management
22:17:22FromDiscord<guttural666> uhm, gonna paste bin real quick
22:18:29FromDiscord<guttural666> https://pastebin.com/TguPwDtE
22:18:53FromDiscord<guttural666> compiling with c and nothing else, latest Nim version
22:19:08FromDiscord<Elegantbeef> So using refc
22:20:39FromDiscord<Elegantbeef> Well then what you're doing is probably sensible
22:20:43FromDiscord<guttural666> I guess yeah
22:20:48FromDiscord<guttural666> okay cool
22:21:57FromDiscord<Elegantbeef> > echos are not thread safe
22:21:57FromDiscord<Elegantbeef> `echo` is threadsafe
22:22:21FromDiscord<Elegantbeef> > Unlike other IO operations this is guaranteed to be thread-safe as echo is very often used for debugging convenience.
22:22:49FromDiscord<guttural666> oh okay
22:23:19FromDiscord<guttural666> not aware of the technical details of stuff like echo or printf, I think I read it was a file or buffer
22:23:33FromDiscord<guttural666> and that cannot be thread safe to just spam around?
22:23:44FromDiscord<Elegantbeef> Well Nim's echo is threadsafe
22:23:55FromDiscord<guttural666> okay that is interesting, so it must lock?
22:24:02FromDiscord<Elegantbeef> Yea
22:25:09FromDiscord<guttural666> interesting, I'm just leaving notes in my code to come back to, I plan to multithread this and test the limits of the server until I get banned for suspected DDoS ^^
22:25:36FromDiscord<guttural666> insane how an API internet response takes up 99,90% of my runtime, JSON parsing and even uniquely inserting stuff into a structure of arrays comparing an id field is just 0,1%
22:26:11FromDiscord<guttural666> I'm timing this as well, it's crazy how much time I/O takes
22:26:55FromDiscord<Elegantbeef> Inb4 you're doing this single threaded
22:26:57FromDiscord<Elegantbeef> Without async
22:27:15FromDiscord<guttural666> at the moment yes
22:27:42FromDiscord<guttural666> initial load of my YAML (LOL) backend takes an hour at the moment
22:27:47FromDiscord<Elegantbeef> Well no shit you're blocked by IO
22:27:50FromDiscord<guttural666> only for the bands
22:28:03FromDiscord<guttural666> yeah yeah, I'm getting there dude ^^
22:28:46FromDiscord<guttural666> when everything is working, I will try to async the whole thing
22:29:37FromDiscord<guttural666> was looking at this bad boy the other day https://github.com/Loki-Afro/metalarchives
22:31:01FromDiscord<guttural666> not trying to do the same thing exactly, but it's good as a reference and to see how horrible Java is
22:43:38*lumo_e joined #nim
23:08:18*jmdaemon quit (Ping timeout: 255 seconds)
23:22:28*jmdaemon joined #nim
23:39:45*lucasta joined #nim
23:43:38FromDiscord<elseif> yo
23:43:41FromDiscord<elseif> can someone explain this to me? https://media.discordapp.net/attachments/371759389889003532/1095494409002418376/image.png
23:43:50FromDiscord<elseif> i don't know what ffi is or what the code does
23:44:11FromDiscord<elseif> (edit) "i don't know what ffi is ... or" added "past "foreign function interface""
23:44:21FromDiscord<Elegantbeef> https://en.wikipedia.org/wiki/Foreign_function_interface
23:56:56FromDiscord<elseif> i'm having some trouble installing nim, i went through the steps of finish.exe but it's still not recognizing nim as a command
23:59:51FromDiscord<huantian> you might need to restart your computer or log out and log back in to get windows to recognize nim in your path? ngl i never remember how windows does it