00:00:22 | FromDiscord | <Phil> Well yeah, that's compile-time polymorphism, that has to work 😛 |
00:01:08 | FromDiscord | <Elegantbeef> hey not everyone knows `C` can dispatch as `A` 😄 |
00:01:22 | FromDiscord | <Phil> Fair, though I just realized something in my way of thinking |
00:01:48 | FromDiscord | <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:52 | FromDiscord | <Phil> Is that actually a true assumption? |
00:02:03 | FromDiscord | <Elegantbeef> Really though Nim should emit compile time errors for any upcasted stack types |
00:02:42 | FromDiscord | <Elegantbeef> Runtime polymorphism is a bit more complicated cause you need RTTI and dynamic dispatch |
00:02:58 | FromDiscord | <Elegantbeef> Which means either a VTable or if statements like Nim presently does for dynamic dispatch |
00:05:53 | FromDiscord | <Elegantbeef> Though RTTI can just be an integer, it's not that much more complicated |
00:15:28 | FromDiscord | <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:36 | FromDiscord | <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:10 | FromDiscord | <Elegantbeef> method is for dynamic dispatch |
01:56:11 | FromDiscord | <Elegantbeef> proc is for static dispatch |
01:56:27 | FromDiscord | <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:35 | FromDiscord | <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:08 | FromDiscord | <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:06 | FromDiscord | <Elegantbeef> Such an awful thing to leave down to compilers |
03:16:25 | FromDiscord | <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:13 | FromDiscord | <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:26 | FromDiscord | <Elegantbeef> Nim does have multimethods |
03:32:33 | FromDiscord | <Elegantbeef> They're deprecated |
03:32:35 | FromDiscord | <Elegantbeef> But they're there |
03:32:50 | FromDiscord | <michaelb.eth> Sure, I looked into that |
03:34:11 | FromDiscord | <michaelb.eth> Not quite the same as multimethod , but I appreciate that there were some real issues |
03:34:44 | FromDiscord | <michaelb.eth> (edit) "Not quite the same as ... multimethod" added "Clojure’s" |
03:34:51 | FromDiscord | <Elegantbeef> Well it doesnt really explain what it does here 😄 |
03:35:06 | FromDiscord | <michaelb.eth> (edit) "multimethod ," => "multimethod," |
03:36:09 | FromDiscord | <michaelb.eth> the page I linked? |
03:36:14 | FromDiscord | <Elegantbeef> Yea |
03:36:16 | FromDiscord | <Elegantbeef> I cannot read the code |
03:36:27 | FromDiscord | <michaelb.eth> never had a scheme/lisp bender? |
03:37:00 | FromDiscord | <Elegantbeef> Of course not i like my sanity |
03:37:19 | FromDiscord | <michaelb.eth> yeah, for sure, it is probably for the best |
03:38:12 | FromDiscord | <Elegantbeef> From cursory reading this seems to use static values to dispatch |
03:38:36 | FromDiscord | <michaelb.eth> will try to translate... give me a min |
03:46:06 | FromDiscord | <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:27 | FromDiscord | <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:43 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4ta7 |
04:22:46 | * | nanxiao quit (Quit: Client closed) |
04:27:24 | FromDiscord | <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:37 | FromDiscord | <michaelb.eth> (edit) "fwiw, Rich Hickey, the creator of Clojure ... described" added "has" |
04:27:55 | FromDiscord | <Elegantbeef> No clue i still have yet given what you wrote a solid read |
04:48:06 | FromDiscord | <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:56 | madprops | trying to find out how to use this to invert colors in the output |
05:03:57 | madprops | https://nim-lang.org/docs/terminal.html |
05:04:02 | madprops | like to highlight some parts of a line |
05:06:02 | FromDiscord | <Rika> styleReverse |
05:06:18 | madprops | ahh |
05:06:19 | madprops | thanks |
05:06:36 | FromDiscord | <Rika> I think that’s the one at least |
05:08:39 | madprops | indeed it is |
05:08:48 | madprops | now i have to do the code to highlight specific parts |
05:30:12 | * | rockcavera quit (Remote host closed the connection) |
05:35:24 | madprops | hmm chatgpt thinks "re" has a "compile" function |
05:36:52 | madprops | let pattern = re.compile(r"brown", re.IGNORECASE) |
05:39:58 | madprops | also got wrong about replacing with a callback |
05:46:19 | FromDiscord | <Rika> Because it probably thinks about python |
05:47:13 | madprops | seeing some example using `=>` in the forum |
05:47:20 | madprops | but that doesn't seem to be an operator |
05:47:28 | FromDiscord | <Rika> It is |
05:47:38 | FromDiscord | <Rika> Imported in sugar module |
05:47:48 | madprops | oh |
06:01:43 | madprops | ok done. now my string finder can highlight https://i.imgur.com/VGWaZn3.jpg |
06:02:42 | madprops | except if the substring is at the cropped end |
06:02:46 | madprops | since i cut long lines |
06:02:54 | madprops | maybe i shouldn't |
06:05:35 | FromDiscord | <Rika> You can also alternatively set both a background and foreground colour for the section |
06:06:11 | madprops | not sure what you mean |
06:08:58 | madprops | https://i.imgur.com/ywnrJ3i.jpg |
06:09:31 | madprops | looks a bit ugly without cutting the lines but it's better to not hide stuff |
06:10:09 | madprops | also has a -h flag to disable highlighting |
06:15:22 | * | kenran joined #nim |
06:22:55 | * | derpydoo quit (Ping timeout: 268 seconds) |
06:27:08 | FromDiscord | <Elegantbeef> @michaelb.eth see i cannot look at fancy type stuff like this, it just drives me to write toys |
06:27:09 | FromDiscord | <Elegantbeef> https://hatebin.com/ikqtpcwgnu |
06:28:03 | FromDiscord | <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:24 | FromDiscord | <Elegantbeef> I do imagine one can emit this type of logic based off of whether `when compiles(isConvertible(param, paramType))` |
06:29:33 | FromDiscord | <Elegantbeef> So it wouldnt just be value based like i wrote here |
06:31:38 | FromDiscord | <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:55 | Amun-Ra | how'd you iterate all the function type vars in a module? |
06:40:59 | Amun-Ra | I mean I plan to write a macro but I don't really know how to get all the vars |
06:41:33 | FromDiscord | <Elegantbeef> There is no way of querying all symbols in a module |
06:42:53 | Amun-Ra | ouch, thanks |
06:43:05 | FromDiscord | <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:52 | Amun-Ra | I have all those vars in an object and I thought I could get rid of it |
06:44:30 | FromDiscord | <huantian> vars? |
06:44:37 | Amun-Ra | variables |
06:44:49 | FromDiscord | <Elegantbeef> We're familiar with the term |
06:44:53 | FromDiscord | <Elegantbeef> We're uncertain what you mean |
06:45:05 | FromDiscord | <huantian> lol i didn't mean like that, I wasn't sure what you mean by a var in an object |
06:46:02 | Amun-Ra | right, sorry ;) |
06:47:04 | Amun-Ra | I have a bunch of cdecl variables and I wanted to assign their values automatically by their names |
06:48:06 | Amun-Ra | for example: var SDL_Init*: proc (x: uint32) {.cdecl.} and init all of them after successful dlsym |
06:48:29 | Amun-Ra | dlopen* |
06:49:32 | FromDiscord | <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:39 | FromDiscord | <Elegantbeef> Or adds them to table |
06:50:11 | Amun-Ra | hmm |
06:52:55 | FromDiscord | <Elegantbeef> I could give you the nimscripter reference that sorta works this way |
06:53:02 | FromDiscord | <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:28 | Amun-Ra | I could give it a try |
06:56:33 | FromDiscord | <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:50 | Amun-Ra | thanks |
06:56:53 | FromDiscord | <Elegantbeef> it calls `addToCache` with the symbol |
06:57:19 | FromDiscord | <Elegantbeef> you can go through there |
06:57:37 | FromDiscord | <Elegantbeef> then `implNimscriptModule` is used to 'finalize' a module |
06:58:05 | FromDiscord | <Elegantbeef> It emits a populated version of https://github.com/beef331/nimscripter/blob/master/src/nimscripter/vmaddins.nim#L8-L11 |
06:58:13 | FromDiscord | <Elegantbeef> Hopefully this helps and doesnt just cause massive confusion |
06:59:58 | * | onetwo joined #nim |
07:02:02 | Amun-Ra | I 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:48 | FromDiscord | <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:19 | FromDiscord | <huantian> What did happen with the docker open source thing |
07:08:36 | FromDiscord | <huantian> I only heard tbe complains not the resolution |
07:08:37 | FromDiscord | <Phil> They backtracked immediately after literally nobody knows if their images would still work come their deadline |
07:08:46 | FromDiscord | <Phil> (edit) "knows" => "knew anymore" |
07:08:53 | FromDiscord | <huantian> Ah |
07:09:09 | PMunch | Backtracked in what way? |
07:09:31 | FromDiscord | <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:42 | PMunch | Right.. |
07:11:38 | * | advesperacit joined #nim |
07:41:15 | * | Notxor joined #nim |
07:42:21 | PMunch | Hmm, is there a way to assign a range in an enum? |
07:42:38 | PMunch | I want to have some values tracked and defined, and others ignored |
07:43:06 | PMunch | Currently parsing as an enum fails with a RangeDefect, but I want it to always pass but just have an "Unknown" value |
07:50:33 | FromDiscord | <Dudugz> I think you can use E.low and E.high to check the range of an enum |
07:51:55 | FromDiscord | <Dudugz> https://nim-by-example.github.io/types/enums/ |
07:56:24 | FromDiscord | <Dudugz> sent a code paste, see https://paste.rs/zPG |
07:58:47 | FromDiscord | <Elegantbeef> Pmunch the playground needs rebooted |
07:58:52 | FromDiscord | <Elegantbeef> Also what about something like https://hatebin.com/mdviojhhaj |
07:59:12 | FromDiscord | <Elegantbeef> Not the most ideal for large ranges, but for smaller ones it's pretty nice |
07:59:32 | FromDiscord | <Elegantbeef> Alternatively you make a massive case statement inside `classify` |
08:00:32 | PMunch | Currently I went with a try/catch for the RangeDefect and just set it to my bad range thing |
08:00:47 | FromDiscord | <Elegantbeef> How awful |
08:00:59 | FromDiscord | <Elegantbeef> Pmunch wants slow code |
08:00:59 | PMunch | @Elegantbeef, I like your solution, but I need the enum values to have specific values and 0 is already taken |
08:01:12 | FromDiscord | <Elegantbeef> Second LUT |
08:01:49 | FromDiscord | <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:05 | FromDiscord | <Elegantbeef> You also could use `-1` |
08:04:02 | PMunch | Crap, playground disk is full again.. |
08:04:29 | PMunch | @Elegantbeef, sure but then I need to pre-populate the LUT and not let the default 0 value do the work :P |
08:04:39 | FromDiscord | <Elegantbeef> https://hatebin.com/arrjkrtnzh take two |
08:04:42 | PMunch | How slow are exceptions by the way? |
08:05:06 | PMunch | Like how much would could you put into not throwing one before it becomes slower |
08:05:10 | FromDiscord | <Elegantbeef> Slow on the bad path fast on the good path |
08:05:36 | FromDiscord | <Elegantbeef> But you're not supposed to catch defects and if someone compiles with `--panics:on` your code will not work |
08:06:33 | PMunch | Fair enough |
08:07:00 | PMunch | I mean this is just my tiny little keypass manager script |
08:07:10 | PMunch | So I'm the only one compiling it |
08:07:17 | PMunch | Oh wait, this is actually libkeepass |
08:07:22 | PMunch | I guess someone else could use that |
08:07:44 | PMunch | But the encryption library it uses doesn't even compile properly with -d:release so I'm not sure.. |
08:08:11 | FromDiscord | <Elegantbeef> Well then if that's the case you do you |
08:08:12 | FromDiscord | <Elegantbeef> 😄 |
08:09:50 | PMunch | Ugh, the playground keeps running out of space |
08:09:55 | PMunch | Stupid docker.. |
08:16:23 | FromDiscord | <Phil> Is the playground image leaking? |
08:16:27 | FromDiscord | <Phil> (edit) "leaking?" => "leaking memory?" |
08:16:31 | PMunch | All docker images are leaking.. |
08:16:40 | * | junaid_ joined #nim |
08:16:56 | FromDiscord | <Phil> Yes, but is it leaking memory specifically :-P? |
08:16:57 | FromDiscord | <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:06 | FromDiscord | <Phil> If so, could be useful to just have an auto-reboot once every 12h or so |
08:17:21 | PMunch | Essentially 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:52 | PMunch | And since the playground runs a new container every time someone runs code it builds up |
08:18:00 | PMunch | Which slowly but surely fills the disk up |
08:18:11 | PMunch | And in time grinds the entire system to a halt |
08:18:20 | FromDiscord | <Phil> Is that something you can deal with via a cronjob or via docker prune ? |
08:18:32 | FromDiscord | <Phil> Like, running docker-prune regularly or sth |
08:25:08 | PMunch | Nope |
08:25:22 | PMunch | Docker prune doesn't clear out those files |
08:27:51 | PMunch | If 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:29 | PMunch | So 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:52 | FromDiscord | <Rika> ncdu |
08:29:00 | FromDiscord | <Rika> Curses like version of du |
08:30:46 | * | nanxiao quit (Quit: Client closed) |
08:47:52 | PMunch | Fair enough |
08:53:24 | PMunch | Hmm, I might have to ditch some of the versions the playground supports |
08:56:36 | PMunch | Okay, I ditched all the pre-1.2 versions |
09:09:33 | PMunch | Hmm, fun.. The Keepass database format has updated, and it changes so much stuff that I need to rewrite libkeepass.. |
09:09:57 | FromDiscord | <Rika> What? |
09:14:43 | PMunch | What do you mean "what?"? |
09:20:16 | FromDiscord | <Rika> Why would that not be updated alongside the format? |
09:21:22 | PMunch | Because I'm the one who wrote the package? |
09:21:29 | PMunch | This is libkeepass-nim |
09:22:25 | PMunch | AFAIK 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:54 | NimEventer | New 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:17 | PMunch | Hmm, so upgrading the playground to the latest Ubuntu LTS means it doesn't have libssl1.0 any longer |
11:23:28 | PMunch | So now the playground doesn't work, and neither does choosenim |
11:25:03 | FromDiscord | <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:07 | PMunch | Okay, playground is back up now |
11:43:05 | FromDiscord | <demotomohiro> !eval echo "Thank you, PMunch!" |
11:43:11 | NimBot | Thank you, PMunch! |
11:44:17 | FromDiscord | <Entikan> @planetis whatever you did works, thank you so much! <3<3<<3<3 |
11:49:50 | PMunch | Also 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:11 | FromDiscord | <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:06 | FromDiscord | <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:50 | FromDiscord | <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:07 | FromDiscord | <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:06 | FromDiscord | <Bloss> rmissions |
15:17:47 | FromDiscord | <Gumbercules> probably - but it's not worth switching to me |
15:18:08 | FromDiscord | <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:23 | FromDiscord | <Gumbercules> too many downsides |
15:22:30 | FromDiscord | <sOkam!> oh, its not timestamp, its modification time, and its in the std/os module. nvm |
15:23:13 | FromDiscord | <jmgomez> comp speed? |
15:29:49 | FromDiscord | <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:11 | FromDiscord | <Gumbercules> also, C++ has the potential to break my hot code reloading - hot reloading C++ is more complicated than C |
15:34:34 | FromDiscord | <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:06 | FromDiscord | <jmgomez> the comp speed if you use something like tcc makes sense |
15:35:31 | FromDiscord | <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:33 | FromDiscord | <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:21 | FromDiscord | <System64 ~ Flandre Scarlet> https://youtu.be/gutR_LNoZw0↵↵So↵Nim ftw! |
17:38:14 | FromDiscord | <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:28 | FromDiscord | <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:42 | FromDiscord | <Gumbercules> We already had a long ass discussion about it yesterday in there |
17:39:15 | FromDiscord | <Gumbercules> Well - not about that specific video but the subject matter the video was covering |
17:40:55 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Yardanico "i think this is": Ah alright, sorry |
17:41:11 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Gumbercules "Well - not about": What do you think about what happened? |
17:41:32 | FromDiscord | <System64 ~ Flandre Scarlet> We can go in #offtopic if you want |
17:41:36 | FromDiscord | <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:22 | PMunch | Hmm, so with variant objects the value will always be stored at the same location, same as a C union, right? |
18:17:11 | PMunch | Is 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:07 | NimEventer | New 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:20 | PMunch | Hmm, is there a way to convert an array of bytes to a string directly? |
19:33:45 | PMunch | Like I have an array[32, byte] which I want to turn into a 32 character long string with those bytes |
19:39:36 | adigitoleo | Just 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:03 | PMunch | Yes |
19:46:30 | PMunch | Try running `nimble --help` and you should be able to find it |
19:50:37 | adigitoleo | ah 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:42 | FromDiscord | <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:39 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> `newSeqOfCap` |
20:20:09 | FromDiscord | <Elegantbeef> `mySeq.setLen(newSize); mySeq.setLen(startSize)` |
20:20:25 | FromDiscord | <Elegantbeef> Though using `add` is still slower than just indexing |
20:42:58 | * | rockcavera quit (Remote host closed the connection) |
20:43:13 | FromDiscord | <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:18 | FromDiscord | <Daniel Belmes> sent a code paste, see https://play.nim-lang.org/#ix= |
20:45:39 | FromDiscord | <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:34 | NimEventer | New post on r/nim by noobpotato: Mixed language (Nim & 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:04 | FromDiscord | <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:13 | FromDiscord | <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:34 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> `newSeqOfCap` allocates a sequence of an exact size |
21:10:16 | FromDiscord | <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:21 | FromDiscord | <Elegantbeef> `add` will place values from 0 to cap and then grow when required |
21:10:26 | FromDiscord | <Elegantbeef> I mean |
21:11:06 | FromDiscord | <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:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tdw |
21:12:29 | FromDiscord | <Dudugz> How fast is Nim's FFI? I mean, most libraries are just static library bindings |
21:12:38 | * | advesperacit quit () |
21:12:40 | FromDiscord | <guttural666> sent a code paste, see https://play.nim-lang.org/#ix=4tdx |
21:13:06 | FromDiscord | <Elegantbeef> A PR could be added to system |
21:13:16 | FromDiscord | <Elegantbeef> You can literally copy the code i wrote |
21:14:11 | FromDiscord | <Elegantbeef> Yea reserve is just the same as setlen and reset it |
21:14:45 | FromDiscord | <Elegantbeef> If you do not have an existent seq though the allocation of a cap is reserve |
21:17:12 | FromDiscord | <guttural666> In reply to @Elegantbeef "If you do not": yes |
21:17:44 | FromDiscord | <guttural666> (edit) "yes" => "no, because you will have a bunch of default initialized stuff, not memory available" |
21:17:57 | FromDiscord | <Elegantbeef> What? |
21:19:05 | FromDiscord | <Elegantbeef> !eval echo newSeqOfCap[int](10) |
21:19:07 | FromDiscord | <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:07 | FromDiscord | <Elegantbeef> Fuuuck |
21:19:11 | NimBot | @[] |
21:19:44 | FromDiscord | <Elegantbeef> Nim 0 inits memory allocations |
21:19:44 | FromDiscord | <Elegantbeef> Regardless |
21:21:12 | * | om3ga quit (Ping timeout: 255 seconds) |
21:21:21 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tdz |
21:21:38 | FromDiscord | <Elegantbeef> Whoops `0..<7` |
21:23:08 | FromDiscord | <guttural666> won't add add 7 elements to the seq making it of len = 17? pretty sure that is what's happening |
21:23:17 | FromDiscord | <Elegantbeef> Nope |
21:23:23 | FromDiscord | <guttural666> ohhhh |
21:23:29 | FromDiscord | <guttural666> will try that out |
21:23:44 | FromDiscord | <Elegantbeef> Cause i reset the `setLen` after |
21:23:46 | FromDiscord | <Elegantbeef> setlen does not shrink the sequence |
21:23:47 | FromDiscord | <Elegantbeef> It only changes the length, not the capacity |
21:24:41 | FromDiscord | <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:00 | FromDiscord | <Elegantbeef> It reserves the amount you specify then future adds will not cause it to grow until it grows over `cap` |
21:25:08 | FromDiscord | <Elegantbeef> `newSeq[T]` is the on that length is the size given |
21:25:57 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/RFCs/issues/97 is an rfc |
21:26:13 | FromDiscord | <guttural666> ohh, that is interesting, so I misunderstood the setLen |
21:26:36 | FromDiscord | <guttural666> so it's basically doing all in one, so add will actually still work |
21:26:53 | FromDiscord | <Elegantbeef> The only way to deallocate memory from a sequence in Nim is to allocate to a new sequence |
21:27:21 | FromDiscord | <Elegantbeef> With that capacity RFC perhaps there'd be another way, but presently that's it |
21:27:37 | FromDiscord | <Elegantbeef> Sequence's `setLen` keeps the memory so you can reuse allocations |
21:31:14 | FromDiscord | <guttural666> nah, that is not correct, add will actually add another elem |
21:31:52 | FromDiscord | <guttural666> https://media.discordapp.net/attachments/371759389889003532/1095461237938204732/image.png |
21:32:19 | FromDiscord | <guttural666> this will give me 123..0..1 with 11 elems |
21:32:19 | FromDiscord | <Elegantbeef> Reread my reserve procedure |
21:32:34 | FromDiscord | <Elegantbeef> I set len to 10 then back to original |
21:32:39 | FromDiscord | <Elegantbeef> Just use the reserve procedure |
21:32:59 | FromDiscord | <guttural666> yeah okay |
21:39:35 | FromDiscord | <guttural666> will resetting a seq from 100k back to 0 actually release the memory back to the system? |
21:41:02 | FromDiscord | <Elegantbeef> Does anyone read what i type? |
21:41:13 | FromDiscord | <Elegantbeef> > The only way to deallocate memory from a sequence in Nim is to allocate to a new sequence |
21:43:03 | FromDiscord | <jmgomez> Hey Beef, by any chance do you have an answer to my question on internals? |
21:43:29 | FromDiscord | <guttural666> In reply to @Elegantbeef "> The only way": sorry yes |
21:50:20 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> Yes |
21:50:45 | FromDiscord | <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:45 | FromDiscord | <Elegantbeef> It's for reuse |
21:50:56 | FromDiscord | <Elegantbeef> Nope jm i do not touch gen code |
21:51:14 | FromDiscord | <Elegantbeef> Generally speaking when you do `setLen(0)` you want to reuse the collection without allocating |
21:51:55 | FromDiscord | <guttural666> In reply to @Elegantbeef "Generally speaking when you": okay, very interesting |
21:52:06 | FromDiscord | <guttural666> thanks for the explanation |
21:54:26 | FromDiscord | <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:49 | FromDiscord | <Elegantbeef> Yep |
22:10:43 | FromDiscord | <Elegantbeef> Though `bands` is a local variable so it'll get GC'd |
22:11:31 | FromDiscord | <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:53 | FromDiscord | <Elegantbeef> It likely gets it to deallocate directly there |
22:12:07 | FromDiscord | <Elegantbeef> But there is hardly a difference between `= @[]` and letting the memory management handle it |
22:14:31 | FromDiscord | <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:02 | FromDiscord | <guttural666> don't want to use any more memory that I need at any time |
22:15:03 | FromDiscord | <Elegantbeef> The right thing to do 9/10 times is let Nim manage your memory 😛 |
22:15:10 | FromDiscord | <guttural666> yeeeeah 😄 |
22:15:21 | FromDiscord | <Elegantbeef> What's the full scope and what mm are you using? |
22:15:33 | FromDiscord | <guttural666> mm? |
22:16:04 | FromDiscord | <Elegantbeef> memory management |
22:17:22 | FromDiscord | <guttural666> uhm, gonna paste bin real quick |
22:18:29 | FromDiscord | <guttural666> https://pastebin.com/TguPwDtE |
22:18:53 | FromDiscord | <guttural666> compiling with c and nothing else, latest Nim version |
22:19:08 | FromDiscord | <Elegantbeef> So using refc |
22:20:39 | FromDiscord | <Elegantbeef> Well then what you're doing is probably sensible |
22:20:43 | FromDiscord | <guttural666> I guess yeah |
22:20:48 | FromDiscord | <guttural666> okay cool |
22:21:57 | FromDiscord | <Elegantbeef> > echos are not thread safe |
22:21:57 | FromDiscord | <Elegantbeef> `echo` is threadsafe |
22:22:21 | FromDiscord | <Elegantbeef> > Unlike other IO operations this is guaranteed to be thread-safe as echo is very often used for debugging convenience. |
22:22:49 | FromDiscord | <guttural666> oh okay |
22:23:19 | FromDiscord | <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:33 | FromDiscord | <guttural666> and that cannot be thread safe to just spam around? |
22:23:44 | FromDiscord | <Elegantbeef> Well Nim's echo is threadsafe |
22:23:55 | FromDiscord | <guttural666> okay that is interesting, so it must lock? |
22:24:02 | FromDiscord | <Elegantbeef> Yea |
22:25:09 | FromDiscord | <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:36 | FromDiscord | <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:11 | FromDiscord | <guttural666> I'm timing this as well, it's crazy how much time I/O takes |
22:26:55 | FromDiscord | <Elegantbeef> Inb4 you're doing this single threaded |
22:26:57 | FromDiscord | <Elegantbeef> Without async |
22:27:15 | FromDiscord | <guttural666> at the moment yes |
22:27:42 | FromDiscord | <guttural666> initial load of my YAML (LOL) backend takes an hour at the moment |
22:27:47 | FromDiscord | <Elegantbeef> Well no shit you're blocked by IO |
22:27:50 | FromDiscord | <guttural666> only for the bands |
22:28:03 | FromDiscord | <guttural666> yeah yeah, I'm getting there dude ^^ |
22:28:46 | FromDiscord | <guttural666> when everything is working, I will try to async the whole thing |
22:29:37 | FromDiscord | <guttural666> was looking at this bad boy the other day https://github.com/Loki-Afro/metalarchives |
22:31:01 | FromDiscord | <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:38 | FromDiscord | <elseif> yo |
23:43:41 | FromDiscord | <elseif> can someone explain this to me? https://media.discordapp.net/attachments/371759389889003532/1095494409002418376/image.png |
23:43:50 | FromDiscord | <elseif> i don't know what ffi is or what the code does |
23:44:11 | FromDiscord | <elseif> (edit) "i don't know what ffi is ... or" added "past "foreign function interface"" |
23:44:21 | FromDiscord | <Elegantbeef> https://en.wikipedia.org/wiki/Foreign_function_interface |
23:56:56 | FromDiscord | <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:51 | FromDiscord | <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 |