00:00:15 | FromDiscord | <jtv> @cletus when your fielditer iterates over "dirs: seq[Edir]" the items are of type Edir, but not when you are iterating over the `files` field. |
00:00:40 | FromDiscord | <jtv> So you're calling dirsize() on a file. |
00:01:55 | FromDiscord | <huantian> Also part of it is using if instead of when like I mentioned |
00:04:42 | FromDiscord | <cletus> In reply to @jtv "<@911198173370937374> when your fielditer": Hi, thanks for replying.. but I thought the else clause in line 47 makes me to start working with Edirs? |
00:04:55 | FromDiscord | <jtv> The code gets generated for each field. |
00:05:21 | FromDiscord | <jtv> Unless you use when, not if |
00:05:31 | FromDiscord | <Haze System (they/them)> alright, figured it out, thanks :) dont fully understand how macros work yet, but figuring it out slowly |
00:05:35 | FromDiscord | <jtv> `when` is a compile-time if statement |
00:05:54 | FromDiscord | <huantian> Also again why are you using fieldPairs? Am I missing something |
00:06:16 | FromDiscord | <jtv> Agreed, that makes 0 sense, I don't pretend to understand what you're really trying to accompilish here |
00:10:53 | FromDiscord | <cletus> In reply to @huantian "Also again why are": I used fieldpairs to be able to get the values in the Edir object... Please can you teach me the correct thing I should have done |
00:12:11 | NimEventer | New post on r/nim by FunnyEaster: Nil in Nim., see https://reddit.com/r/nim/comments/116sf7v/nil_in_nim/ |
00:13:03 | FromDiscord | <jtv> In general, iterate over a directory's contents, test to see if it's a file or a directory (it can also be a link btw) and then take action depending on that. Don't understand why you need to enumerate an object's fields instead there of just accessing the fields you need at any given time |
00:13:36 | FromDiscord | <jtv> That kind of tool is not meant for many things... mainly things like generic serialization routines where you won't know the fields you need to look at in advance |
00:15:09 | FromDiscord | <cletus> sorry but I need to know the size of the Edir to be able to solve the Advent of code challenge..... the code is not for any practical purpose |
00:15:35 | FromDiscord | <jtv> Sure, you can test it at runtime, when it's a directory |
00:16:09 | FromDiscord | <jtv> You don't need to iterate over field names in an object where you're not sure what field names are going to be there |
00:16:24 | FromDiscord | <jtv> Which is the whole point of the field iteration primitives |
00:16:28 | FromDiscord | <cletus> Oh, I see!!.. I should actually implement the directory structure on my machine |
00:18:11 | FromDiscord | <jtv> No |
00:18:44 | FromDiscord | <jtv> I'm saying you should keep track of what's a file and what's a dir using separate fields and then operate on them depending on the type |
00:19:16 | FromDiscord | <jtv> You probably should be using a type variant |
00:19:51 | FromDiscord | <jtv> Assuming you're reconstructing a file system tree, where there are files at the leaves |
00:20:36 | FromDiscord | <huantian> In reply to @cletus "I used fieldpairs to": Just access the values directly |
00:21:05 | FromDiscord | <huantian> I.e. dir.files |
00:21:13 | FromDiscord | <huantian> dir.does |
00:21:17 | FromDiscord | <huantian> (edit) "dir.does" => "dir.dirs" |
00:21:59 | FromDiscord | <jtv> I'm assuming he wants to have a tree with some "node" object as children that may have children if it's a directory... thus, would use a variant type |
00:22:22 | FromDiscord | <huantian> the current setup should work though |
00:22:46 | * | derpydoo quit (Quit: derpydoo) |
00:23:04 | FromDiscord | <jtv> Sure, just trying to help cletus learn to structure things a bit more naturally by learning about some of the common features they should know about 🙂 |
00:24:04 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4oBh |
00:24:06 | FromDiscord | <huantian> this should work I think? |
00:24:16 | FromDiscord | <huantian> (asking jtv, spoilering so I don't spoil the solution for you hehe) |
00:24:46 | FromDiscord | <cletus> In reply to @jtv "I'm saying you should": Thanks a lot, let me do that....... Just in case anyone is wondering, implementing the filesystem on your machine is so horrible: https://gist.github.com/Uzo2005/4f1ae3d256d999a199161278a48bb1ce, this code drops a 15Gb directory on your machine!!! 😆 |
00:25:42 | FromDiscord | <jtv> I mean, it'll work given the bit that's there, but still needs to do the parsing and get the file system model right, which pretty much has to be a tree of some sort, and that isn't there yet |
00:25:45 | FromDiscord | <jtv> So hard to say |
00:25:51 | FromDiscord | <cletus> In reply to @huantian "Just access the values": Thanks a lot... in hindsight, this was what I should have done, Thanks again |
00:26:06 | FromDiscord | <huantian> In reply to @jtv "Sure, just trying to": true I think I solved it this way myself |
00:29:17 | FromDiscord | <Hourglass [She/Her]> Do shared libraries have major performance dips? |
00:29:24 | FromDiscord | <jtv> No |
00:29:45 | FromDiscord | <huantian> executables do tho so you might want to avoid those /j |
00:30:49 | FromDiscord | <Hourglass [She/Her]> So there's no point to make it so my system could be compiled together as a single binary? |
00:32:20 | FromDiscord | <Hourglass [She/Her]> (What's funny is how easily it'd work, since the main thing my plugin system relies on is a `plugin` object and `symAddr`(?) on `LibHandle`, which I can probably abuse by using a concept and some macro hell |
00:32:41 | FromDiscord | <jtv> The main reason you might choose static linking is if you're afraid people might not be able to get the dynamically loaded dependencies working, or might have some sort of versioning conflict problems |
00:32:57 | Amun-Ra | that's what I'd doing in my project, symaddrs |
00:33:44 | FromDiscord | <Hourglass [She/Her]> Versioning conflicts? |
00:33:59 | FromDiscord | <Elegantbeef> Most people choose it cause "one file good"↵(@jtv) |
00:34:38 | FromDiscord | <jtv> Yes, @ElegantBeef we are saying the same thing. One file is good particularly because dealing w/ dependencies can lead to problems |
00:34:49 | FromDiscord | <Elegantbeef> No you misunderstand |
00:34:56 | FromDiscord | <Elegantbeef> I mean the sole reason they use it is cause "one file good" |
00:35:22 | FromDiscord | <Elegantbeef> The fact it handles dependency issues is unrelated |
00:35:24 | FromDiscord | <jtv> @Hourglass [She/Her] Yes, let's say you're dynamically linking to libssl.so |
00:35:39 | FromDiscord | <jtv> There are many different versions that can be present, sometimes at the same time |
00:36:32 | FromDiscord | <jtv> Well, getting something that's truly fully static w/o even a libc dependency is a bit of a PITA, musl has some gaps relative to standard libc |
00:36:43 | FromDiscord | <Hourglass [She/Her]> In reply to @Elegantbeef "I mean the sole": I mean, it's good if someone knows nothing about how to install the dependencies ig? |
00:36:54 | FromDiscord | <Hourglass [She/Her]> In reply to @jtv "Well, getting something that's": Fair |
00:37:45 | FromDiscord | <jtv> Frankly, I'd rather just ship a single binary whenever possible, and not worry about the dependency management. There's a reason golang for a long time ONLY generated static binaries and skipped libc, etc |
00:38:16 | FromDiscord | <Elegantbeef> Yea the benefits for static linking are quite nice 😄 |
00:38:17 | FromDiscord | <jtv> But there are good use cases for dynamic linking as well. |
00:38:36 | FromDiscord | <jtv> Yup, especially link time optimizations if you're not doing any dynamic loading |
00:38:52 | FromDiscord | <Hourglass [She/Her]> In reply to @jtv "Frankly, I'd rather just": That's fair enough |
00:39:17 | FromDiscord | <Hourglass [She/Her]> Hm... Hey Beef, how would I abuse macro hell to implement 'symAddr' for a Nim file? |
00:39:25 | FromDiscord | <Elegantbeef> What? |
00:41:04 | FromDiscord | <Iliketwertles> is there any integrated way to reboot with nim? or anything to do with users like logging out and such |
00:42:05 | FromDiscord | <Hourglass [She/Her]> Basically, my plugin system relies on `symAddr` from `dynlib` for getting the procs it needs, since it loads shared libraries↵↵But in theory, I could compile the plugins and the server together (and a bit of hackery to register a plugin), but I'd need to be able to implement `symAddr` for accessing procs in a module |
00:42:08 | FromDiscord | <Hourglass [She/Her]> Hm actually |
00:43:08 | FromDiscord | <Hourglass [She/Her]> I can't actually test this idea rn but i definitely have a way to implement it :p |
00:43:23 | FromDiscord | <jtv> That's super OS dependent, @Iliketwertles. Linus has a reboot() system call for instance, but it's not portable |
00:44:08 | FromDiscord | <jtv> Most people would just run a shell command from the language for unix machines (shutdown) which will be more portable, than do something else from Windows |
00:44:30 | * | sagax quit (Quit: Konversation terminated!) |
00:44:44 | FromDiscord | <jtv> I mean, if you want to statically compile, why the heck use a plugin system? |
00:44:56 | FromDiscord | <Iliketwertles> could i use the reboot() system call somehow? |
00:45:02 | FromDiscord | <jtv> Link-time optimization can ensure you pay no price for the stuff you don't use |
00:45:18 | FromDiscord | <jtv> Sure, via importc |
00:45:19 | FromDiscord | <Iliketwertles> i dont intend to support windwos |
00:45:22 | FromDiscord | <Iliketwertles> (edit) "windwos" => "windows" |
00:46:29 | FromDiscord | <jtv> I don't remember the prototype for reboot, you'd have to man it, but on the nim side you'd use the cdecl / importc pragmas |
00:46:37 | FromDiscord | <Hourglass [She/Her]> In reply to @jtv "I mean, if you": Curiosity and because I can? :P |
00:47:35 | FromDiscord | <Hourglass [She/Her]> Theoretically both could be supported anyway, and since it should be possible to use my Minecraft server impl as a library, you could easily bundle in plugins perhaps? |
00:49:19 | FromDiscord | <Hourglass [She/Her]> In reply to @jtv "Link-time optimization can ensure": How does link-time optimisation work? Since I'm loading shared libraries with `loadLib` |
00:49:22 | FromDiscord | <jtv> Personally I just would focus on the important functionality before the stuff you might consider when you have tons of users. You'll get discouraged less quickly if you're making something where you can show of the value faster 🙂 |
00:49:37 | FromDiscord | <Hourglass [She/Her]> Fair, that's a good point |
00:49:49 | FromDiscord | <jtv> Generally if you can load things after main() is called, you don't use link-time optimization |
00:50:14 | FromDiscord | <Iliketwertles> sent a code paste, see https://play.nim-lang.org/#ix=4oBn |
00:50:17 | FromDiscord | <Iliketwertles> might be called something other than reboot |
00:50:21 | FromDiscord | <Iliketwertles> but the general idea |
00:50:31 | FromDiscord | <Hourglass [She/Her]> I should focus on getting the packet generation working first then work on implementing the login sequence and then everything else |
00:50:40 | FromDiscord | <jtv> The compiler essentially keeps info around and the loader essentially calls it to act depending on what's being linked. |
00:50:55 | FromDiscord | <jtv> So, for instance, if a call only ever gets called once, it can be fully inlined |
00:51:22 | FromDiscord | <jtv> Lots of things you can do once you've effectively "sealed" what's going into the executable |
00:51:54 | FromDiscord | <jtv> But if you use dlopen() (including dynlib, which uses it), you aren't ever doing that because the loader cannot know |
00:52:18 | FromDiscord | <Hourglass [She/Her]> Yeah that makes sense |
00:53:01 | FromDiscord | <Hourglass [She/Her]> So then my code would not work with lto because obviously, dynlib |
00:54:03 | FromDiscord | <jtv> @Iliketwertles I believe that, despite explicitly specifying the implementation is in C, you still need to specify the calling convention as cdecl |
00:54:13 | FromDiscord | <jtv> And I am pretty sure reboot() takes at least one parameter |
00:54:25 | FromDiscord | <jtv> If you don't get that right, expect a crash |
00:54:45 | FromDiscord | <Iliketwertles> seems to complicated when i can just pass a shell command tbh |
00:54:49 | FromDiscord | <Iliketwertles> prob just gonna do that |
00:55:19 | FromDiscord | <jtv> It's a good skill to have, and it really is a one-liner |
00:55:50 | FromDiscord | <jtv> On my linux box, I see: int reboot(int magic, int magic2, int cmd, void arg); |
00:55:58 | FromDiscord | <jtv> But on my mac it's int reboot(int magic); |
00:55:58 | FromDiscord | <Iliketwertles> luckily regardless of init system, `reboot` works assuming proper privilages are granted to the given user |
00:56:17 | FromDiscord | <Iliketwertles> linux wise at least |
00:56:41 | FromDiscord | <jtv> So you'd have to declare your nim function to take (cint, cint, cint, pointer) |
00:57:20 | FromDiscord | <jtv> There is a glibc reboot() that only takes the one int like the os x version, so that's easier and more portable I guess |
00:58:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oBo |
00:59:19 | FromDiscord | <Hourglass [She/Her]> That is indeed code Beef |
00:59:31 | FromDiscord | <Hourglass [She/Her]> More work on your Nim to C lib? |
00:59:58 | FromDiscord | <jtv> sent a code paste, see https://play.nim-lang.org/#ix=4oBp |
01:00:54 | FromDiscord | <Elegantbeef> Yes |
01:01:18 | FromDiscord | <Hourglass [She/Her]> Sounds fun if you like pain |
01:01:34 | FromDiscord | <jtv> @ElegantBeef hangs out here, so clearly likes pain 🙂 |
01:01:48 | FromDiscord | <Elegantbeef> I mean it presently isnt too bad |
01:02:01 | FromDiscord | <Elegantbeef> I am reusing a lot of cgen, but adapting it for my usees |
01:02:39 | FromDiscord | <Elegantbeef> I'm mostly just bodging this together so far and it's like \< 400 loc |
01:03:48 | FromDiscord | <Elegantbeef> Nim does have the now deprecated `--header` parameter, but it's supposed to not be used |
01:07:54 | FromDiscord | <Hourglass [She/Her]> Are they removing it in 2.0? |
01:09:31 | FromDiscord | <Elegantbeef> I do wonder what the best for ABI is, I'm thinking forcing `cdecl` on all procs and using packed on objects.... |
01:09:50 | FromDiscord | <Elegantbeef> Not that i know of |
01:09:56 | FromDiscord | <Elegantbeef> Deprecated just means "do not use" mostly |
01:09:59 | FromDiscord | <Elegantbeef> Also it will not be supported |
01:13:37 | FromDiscord | <Hourglass [She/Her]> Ah |
01:15:37 | FromDiscord | <Patitotective> i'm kind of confused with `char`s because `char.high` is 255 but `'ñ'` is invalid↵does `char` actually only works until 127 or am i messing something up? :/ |
01:18:11 | FromDiscord | <Elegantbeef> It might only support ascii inside character literals |
01:19:13 | FromDiscord | <Elegantbeef> It's a good first issue |
01:19:36 | * | brobot quit (Remote host closed the connection) |
01:23:47 | FromDiscord | <Patitotective> In reply to @Elegantbeef "It might only support": i don't get what you mean, isn't `ñ` also ascii? i read that ascii was at first only 7-bit thus 128 characters but aren't nim chars 8-bit? |
01:23:58 | FromDiscord | <Elegantbeef> ascii extended |
01:24:19 | FromDiscord | <Elegantbeef> Ascii is only 127 characters, ascii extended is 255 |
01:24:40 | FromDiscord | <Elegantbeef> `char` is a unsigned byte, but the lexer does not properly lex the character |
01:24:49 | FromDiscord | <Elegantbeef> Hence why i said it's a good first issue |
01:25:01 | FromDiscord | <Patitotective> oh ok |
01:26:39 | FromDiscord | <Elegantbeef> you can luckily do `'\244'` or w/e |
01:42:47 | * | xet7 quit (Quit: Leaving) |
01:46:23 | FromDiscord | <emmikat> i was able to get an async socket across threads by calling getFd, unregistering, starting a thread, and registering |
01:46:37 | FromDiscord | <emmikat> this seems like it should be generally stable |
01:48:24 | FromDiscord | <emmikat> is there any reason it wouldn't be? |
01:49:08 | FromDiscord | <Elegantbeef> Only time will tell |
01:49:20 | FromDiscord | <emmikat> lmao okey |
01:49:27 | FromDiscord | <emmikat> i'll impl it |
01:49:44 | FromDiscord | <emmikat> i implemented it in a test app and it seems fine |
01:50:07 | FromDiscord | <emmikat> i did try seeing what happened recving on multiple threads and rhe last one started got all the messages |
01:50:08 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4oBB |
01:50:18 | FromDiscord | <Elegantbeef> `varags` |
01:50:21 | FromDiscord | <Elegantbeef> `varargs` even |
01:50:27 | FromDiscord | <emmikat> and making the last one exit dropped me to the second last |
01:50:30 | * | derpydoo joined #nim |
01:50:36 | FromDiscord | <emmikat> trying to exit that one segfaulred |
01:50:57 | FromDiscord | <emmikat> oh esp because it was a buffered socket lol |
01:51:11 | FromDiscord | <sOkam!> In reply to @Elegantbeef "`varargs` even": where does that go? in the field? does the parameter have a name? or does it go in the importc properties? |
01:51:27 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#foreign-function-interface-varargs-pragma |
01:52:21 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4oBC |
01:58:32 | FromDiscord | <heinthanth> sent a code paste, see https://play.nim-lang.org/#ix=4oBF |
01:59:10 | FromDiscord | <heinthanth> I need to check `fnName` is declared because I want to generate another code if it's not declared yet. |
01:59:18 | FromDiscord | <Elegantbeef> I'd say do not use bind sym |
02:00:02 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oBG |
02:01:23 | FromDiscord | <heinthanth> sent a code paste, see https://play.nim-lang.org/#ix=4oBI |
02:01:35 | FromDiscord | <Elegantbeef> Yes i'm saying emit that code i showed |
02:04:21 | FromDiscord | <heinthanth> sent a code paste, see https://play.nim-lang.org/#ix=4oBJ |
02:05:36 | FromDiscord | <heinthanth> sent a code paste, see https://play.nim-lang.org/#ix=4oBK |
02:06:43 | FromDiscord | <heinthanth> The first variant is shorter. That's why I'm finding a way to check sym |
02:08:02 | FromDiscord | <heinthanth> Anyway, Thanks ... I gonna try to emit `when declared()` |
02:08:25 | FromDiscord | <Elegantbeef> Yep that's more sane then using bindSym + dynamic bind |
02:08:27 | FromDiscord | <Elegantbeef> I'd personally use distinct typing with a converter for this but to each their own 😄 |
02:10:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oBM |
02:10:56 | FromDiscord | <Elegantbeef> Something like this is a bit more sane imo, but ymmv 😄 |
02:11:23 | FromDiscord | <Elegantbeef> Using the type system to convert down instead of a macro |
02:11:42 | FromDiscord | <Elegantbeef> Though i guess you're avoiding a case statement |
02:11:46 | FromDiscord | <Elegantbeef> So this doesnt help much |
02:16:55 | FromDiscord | <Yepoleb> In reply to @emmikat "i was able to": That should work quite well |
02:17:12 | * | brobot joined #nim |
02:17:30 | FromDiscord | <Yepoleb> About as clean as it gets |
03:11:36 | NimEventer | New thread by DougT: Question on GTK3 mouse processing, see https://forum.nim-lang.org/t/9912 |
03:56:13 | FromDiscord | <emmikat> In reply to @Yepoleb "About as clean as": yayyy neat |
03:56:39 | * | arkurious quit (Quit: Leaving) |
03:57:15 | * | rockcavera quit (Remote host closed the connection) |
04:28:59 | * | dropkick quit (Ping timeout: 248 seconds) |
04:49:46 | * | pbsds quit (Ping timeout: 252 seconds) |
04:53:53 | * | azimut quit (Ping timeout: 255 seconds) |
05:22:44 | * | pbsds joined #nim |
06:02:45 | * | ltriant quit (Ping timeout: 255 seconds) |
06:38:24 | * | brobot quit (Quit: ERROR STOP) |
07:17:03 | * | kenran joined #nim |
07:41:51 | FromDiscord | <Phil> Could somebody give me a rundown what the deadcodeelim pragma did?↵Folks want to remove it off the ndb fork and I officially have no clue what implications that code change has |
07:43:28 | FromDiscord | <amadan> Basically it would turn on Nim's dead code eliminator (i.e. remove functions that aren't used)↵But that has been the default for ages and doesn't do anything anymore |
07:44:10 | FromDiscord | <amadan> https://github.com/nim-lang/Nim/pull/21277 is now deprecated on devel, don't think it has done anything for a while though |
07:44:50 | FromDiscord | <amadan> (edit) "Basically it would turn on Nim's dead code eliminator (i.e. remove functions ... thatisn't" added "and other stuff" | "aren't" => "isn't" |
07:45:04 | FromDiscord | <Elegantbeef> Correct it hasnt done anything since before 1.0 |
07:49:30 | FromDiscord | <Phil> Tests Say okay, I'll push the button once off work |
07:52:44 | FromDiscord | <Elegantbeef> This reminds me of the compile time version of this..... lazy sem |
07:52:57 | FromDiscord | <Elegantbeef> I learned recently that zig uses lazy semantic analysis |
07:53:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oCp |
07:55:34 | FromDiscord | <ringabout> When it comes to experimental features, `experimental:codeReordering` will not work at the top level, so it might be removed from `db_connector/db_sqlite` https://github.com/nim-lang/db_connector/issues/16 and no more silly warnings like "Warning: Circular dependency detected. `codeReordering` pragma may not be able to reorder some nodes properly". |
07:56:01 | FromDiscord | <ringabout> (edit) "properly"." => "properly" for simply importing `import db_connector/db_sqlite`." |
07:56:24 | FromDiscord | <Phil> What does that change for db_? Does that lead to limitations? |
07:57:24 | FromDiscord | <ringabout> `db_connector/db_sqlite` uses `{.experimental: "codeReordering".}`, but is not needed ad should be replaced with forward declarations. |
07:57:36 | FromDiscord | <ringabout> (edit) "ad" => "and" |
07:59:22 | FromDiscord | <ringabout> In reply to @Isofruit "What does that change": Yeah, the parsing stragtegy might change, using `{.experimental: "codeReordering".}` at the top level won't work anymore, which needs to pass it explicitly on the command line: `--experimental:codeReordering`. |
08:01:05 | * | PMunch joined #nim |
08:12:08 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oCz |
08:14:01 | FromDiscord | <Elegantbeef> `except CatchableError: ....` |
08:14:40 | FromDiscord | <4zv4l> what does it change ? |
08:15:01 | FromDiscord | <Rika> You can only catch catchable errors? |
08:15:17 | FromDiscord | <4zv4l> well if I cannot catch them it will just crash anyway right ? |
08:15:33 | PMunch | Ugh, why is the bare except clause deprecated <_< |
08:15:46 | FromDiscord | <Elegantbeef> Cause Defects exist |
08:15:57 | FromDiscord | <Elegantbeef> And people can catch them |
08:15:59 | PMunch | It should rather default to CatchableError and then have to explicitly say except Defect to catch those |
08:16:25 | FromDiscord | <Elegantbeef> The issue is that changes the behaviour |
08:16:33 | PMunch | (maybe with a nice hint that catching defects is a bad idea) |
08:16:39 | FromDiscord | <Elegantbeef> So code behaviour changes slightly that is nigh undetectable 😄 |
08:16:57 | PMunch | Sounds like a good change for 2.0 then |
08:17:27 | FromDiscord | <Elegantbeef> I mean I agree that bear should be CatchableError |
08:17:30 | FromDiscord | <Elegantbeef> bare even |
08:17:31 | PMunch | And the only behaviour that changes is for people who catches defects, which they shouldn't do anyways.. |
08:17:44 | FromDiscord | <Elegantbeef> Except due to lack of education people do |
08:17:55 | FromDiscord | <Elegantbeef> `--panics:on` default please 😄 |
08:18:23 | PMunch | Yeah panics:on and bare except means CatchableError should really be in Nim 2.0 |
08:19:01 | PMunch | The decision has already been made that there are errors you should be able to catch and those you shouldn't be able to catch. No reason to default to allow catching uncatchable errors |
08:19:27 | FromDiscord | <Rika> I think it is unreasonable to have this change for as long as defects aren’t tracked by raises |
08:19:42 | FromDiscord | <Rika> Or tracked in another way of course |
08:20:19 | FromDiscord | <ringabout> There are still cases which need to catch everything like assertions and unittests. |
08:21:24 | FromDiscord | <ringabout> Perhaps in that case, we need a new pragmas like `except {.all.}`. |
08:21:34 | FromDiscord | <ringabout> (edit) "pragmas" => "pragma" |
08:25:46 | FromDiscord | <Elegantbeef> The complexity of that joke is too high i know 😄 |
08:26:12 | FromDiscord | <BobBBob> say, why does the generated html docs have a semicolon separating func parameters? |
08:26:24 | FromDiscord | <Elegantbeef> It's more clear |
08:26:43 | FromDiscord | <Elegantbeef> It's an alternative syntax that is valid |
08:27:03 | FromDiscord | <BobBBob> But like why? |
08:27:09 | FromDiscord | <Elegantbeef> I just said why |
08:27:18 | FromDiscord | <BobBBob> It doesnt do that for procs, what's the difference |
08:27:42 | FromDiscord | <Elegantbeef> Are you sure? |
08:27:49 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/hashes.nim#L75 |
08:27:52 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1077144543486545960/image.png |
08:27:54 | FromDiscord | <BobBBob> oh Im looking at something else |
08:28:24 | FromDiscord | <BobBBob> so is it recommended to use ; in code or what? |
08:28:38 | FromDiscord | <Elegantbeef> Whoops i grabbed the wrong image |
08:28:39 | FromDiscord | <Elegantbeef> It's up to you |
08:28:42 | FromDiscord | <Elegantbeef> It's more clear |
08:28:55 | FromDiscord | <Elegantbeef> I personally never use `;` in anything but generic parameters where it's required |
08:29:22 | FromDiscord | <BobBBob> I see |
08:55:57 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oCJ |
08:56:01 | PMunch | @ringabout, or just `except Exception` which would catch both Defects and CatchableErrors. This RFC is pretty much exactly what I'd want https://github.com/nim-lang/RFCs/issues/360 |
08:57:49 | PMunch | Huh, I thought NEP-1 said semicolon between args, but I can't find it |
08:58:12 | * | randomuser464876 joined #nim |
08:58:54 | PMunch | The argument goes that separating by `;` is more clear and will prevent you from accidentally forgetting a type. `proc test(x, y: int)` is valid and now both x and y are integers, but `proc test(x; y: int)` is invalid. |
08:59:33 | PMunch | But yeah, it's not very commonly used, I think Araq is amongst the few |
09:00:42 | FromDiscord | <ringabout> It used in the compiler I think. I saw a few. |
09:04:32 | FromDiscord | <arnetheduck> In reply to @PMunch "<@658563905425244160>, or just `except": given that 360 was not accepted, the second best option would be to have `except:` map to `except CatchableError:` and not catch defects - this was deemed unacceptable, so the warning is the least bad option remaining - all of these issues hail from the general unsoundness of the exception hierarchy: there are too many conflicting predicates upon which this whole mess |
09:06:20 | FromDiscord | <arnetheduck> ergo, the only remaining sound option is to avoid exceptions entirely or live with the warts 🙂 |
09:08:58 | PMunch | Hmm, that's unfortunate.. |
09:09:14 | PMunch | I'd much rather we actually overhauled the system for 2.0 and broke some code |
09:09:23 | FromDiscord | <ringabout> Yeah, it is also not on the Roadmap 2023. I probably won't work on exceptions recently. This week, I'm going to try removing passes from the compiler, which is also part of the Roadmap. |
09:09:25 | FromDiscord | <arnetheduck> fun fact: `CatchableError` was deliberately chosen as an ugly name that people would never use in code, except to declare deriving exceptions |
09:09:32 | PMunch | It's a painful band-aid to rip, but it would be worth it |
09:10:25 | PMunch | Quite silly that `CatchableError` has the ugly name and `Defect` is the name for the one you really shouldn't be using.. |
09:11:38 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oCN |
09:11:39 | PMunch | Hmm, is there any way to tell Nim that it should clear out all memory? The scenario is a dynamic library unloading, the process won't quit, so the memory isn't auto-freed, so I think Nim would keep global variables around |
09:12:40 | FromDiscord | <arnetheduck> In reply to @4zv4l "is there a way": `if (let a = someStuff; a): echo a` - `a` has to be a boolean though |
09:12:49 | PMunch | https://play.nim-lang.org/#ix=4oCO |
09:12:59 | PMunch | @4zv4l ^ |
09:13:55 | FromDiscord | <arnetheduck> we use that construct when avoiding exceptions: `if (let x = someResult(); x.isOk): echo x.get()` |
09:14:26 | FromDiscord | <ringabout> In reply to @PMunch "Hmm, is there any": I don't know. See also https://discord.com/channels/371759389889003530/768367394547957761/878342840650985513 |
09:17:09 | FromDiscord | <ringabout> > when should globals be destroyed ? for dynamically loaded libraries, IMO we should destroy globals when the library is unloaded |
09:18:22 | FromDiscord | <4zv4l> In reply to @arnetheduck "we use that construct": `isOK` is to check if it's nil or not ? |
09:18:36 | FromDiscord | <4zv4l> In reply to @arnetheduck "`if (let a =": not a boolean unfortunately xD |
09:19:33 | FromDiscord | <arnetheduck> In reply to @4zv4l "`isOK` is to check": if you want to check for nil, check for nil: `if (let x = someRef(); x != nil): ...` |
09:23:12 | FromDiscord | <ringabout> The I will recommend to (mis)use converters in this case for fun 😜 https://nim-lang.org/docs/manual.html#converters |
09:25:18 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4oCQ |
09:28:22 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oCS |
09:29:07 | PMunch | @ringabout, yeah I believe there should be destructors for globals added in a `__attribute((destructor))__` call (Or DllMain with DL_PROCESS_DETACH check), but analogous to --noMain there should be a --noQuit and allow us to import it and call it manually like we can for NimMain |
09:29:15 | FromDiscord | <4zv4l> cast did the trick |
09:30:19 | PMunch | You cast a non-bool to a bool? |
09:30:41 | FromDiscord | <amadan> sent a code paste, see https://play.nim-lang.org/#ix=4oCT |
09:30:57 | FromDiscord | <4zv4l> In reply to @PMunch "You cast a non-bool": oh that was with the UINT |
09:31:35 | * | Mister_Magister quit (Quit: bye) |
09:31:48 | PMunch | Right.. |
09:32:38 | FromDiscord | <ringabout> In reply to @PMunch "<@658563905425244160>, yeah I believe": @PMunch, I agree. |
09:33:06 | FromDiscord | <ringabout> In reply to @amadan "Implement pythons walrus if": Cool |
09:33:36 | PMunch | Hmm, I guess in the meantime calling `GC_unref` on all globals and then a `GC_FullCollect` would work |
09:33:36 | * | Mister_Magister joined #nim |
09:33:37 | PMunch | Maybe |
09:34:50 | FromDiscord | <4zv4l> how do I make a cstring of a certain size ? |
09:35:02 | PMunch | alloc0() |
09:35:31 | PMunch | Well, you could also pass `myString[0].addr` |
09:35:49 | FromDiscord | <4zv4l> `var filename = newString(260).cstring`↵is this valid ? |
09:37:05 | PMunch | Well, kinda |
09:37:19 | PMunch | It is valid as in your code should compile |
09:37:33 | PMunch | But that string now doesn't have any references so the GC will just collect it |
09:38:13 | PMunch | `var filename = cast[cstring](alloc0(260))` there you manually allocate 260 bytes, these then have to be freed later on |
09:38:18 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4oCW |
09:43:28 | * | randomuser464876 quit (Ping timeout: 260 seconds) |
09:45:30 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oCZ |
09:46:23 | * | randomuser464876 joined #nim |
09:47:18 | FromDiscord | <4zv4l> is the problem `SHSTDAPI_` ? |
09:47:58 | FromDiscord | <4zv4l> which is defined to `STDAPI_(type)` |
09:48:28 | FromDiscord | <4zv4l> oh no |
09:48:37 | FromDiscord | <4zv4l> it's defined as↵`#define SHDOCAPI_(type) DECLSPEC_IMPORT type STDAPICALLTYPE` |
09:49:02 | FromDiscord | <4zv4l> (edit) "SHDOCAPI_(type)" => "SHSTDAPI_(type)" |
09:49:23 | FromDiscord | <4zv4l> how can I fix that ? |
09:54:33 | FromDiscord | <Rika> most of us are not acquainted with the windows api |
09:58:40 | FromDiscord | <sOkam!> I'm using the compile pragma to compile two different C files both called `core.c`, which are part of their respective `one` and `two` subfolders, but instead of being built as `nimcache/[email protected]` they both end up as `nimcache/core.c.o` and crash the linker due to repeated symbols↵Is there a way to instruct the compile pragma to output with a unique name, or to a different folder, so this doesn't happen, without having to rename the |
09:59:37 | * | ltriant joined #nim |
09:59:49 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4oD5 |
10:03:43 | * | ltriant quit (Ping timeout: 246 seconds) |
10:09:10 | PMunch | sOkam, there seems to be a way to pass separate flags: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compile-pragma |
10:09:29 | PMunch | But not sure if Nim would find it if you compiled it to a different location :P |
10:19:56 | PMunch | @ringabout, created an issue to track this: https://github.com/nim-lang/Nim/issues/21403 |
10:20:27 | FromDiscord | <ringabout> Nice! |
10:22:41 | * | ltriant joined #nim |
10:22:52 | Amun-Ra | PMunch: you can't be even sure all the memory is freed by dclose in plain old C |
10:23:05 | Amun-Ra | SDL2 is the perfect example |
10:23:39 | Amun-Ra | but I see the issue |
10:23:40 | FromDiscord | <4zv4l> In reply to @demotomohiro "You probably need to": I changed from `shellapi.h` to `shell32` and it worked |
10:38:03 | FromDiscord | <federico3> https://arxiv.org/abs/2302.05331 "C-rusted\: The Advantages of Rust, in C, without the Disadvantages" |
10:41:35 | FromDiscord | <federico3> the table about tooling and code reuse, portability, and incremental adoption could be relevant for Nim |
11:28:34 | FromDiscord | <Hourglass [She/Her]> What's a clever name for a NBT library in Nim :p |
11:29:09 | FromDiscord | <Hourglass [She/Her]> I've named my Minecraft packet wrapping library as `Napkins`, the server itself is called `Nimberite` |
11:33:57 | * | azimut joined #nim |
11:43:14 | NimEventer | New thread by WizardUli: Heap fragmentation, embedded systems, see https://forum.nim-lang.org/t/9914 |
11:45:04 | * | crem1 quit (Quit: WeeChat 3.7.1) |
11:51:17 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4oDt |
11:51:34 | FromDiscord | <4zv4l> because when I add this to my dll it doesn't wanna load anymore |
11:52:23 | FromDiscord | <Rika> i dont see how that would happen |
12:02:00 | FromDiscord | <4zv4l> well when I add an iterator it's makes my dll unable to load idk why |
12:07:19 | FromDiscord | <4zv4l> oh it's `copyFile` that does that |
12:09:11 | FromDiscord | <4zv4l> why would `copyFile` make that error |
12:09:34 | FromDiscord | <4zv4l> `[-] LoadLibrary(): 126`↵I cannot load the dll if I add `copyFile` lmao |
12:23:21 | * | jmdaemon quit (Ping timeout: 252 seconds) |
12:23:38 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4oDF |
12:23:44 | FromDiscord | <Hourglass [She/Her]> I'm defining it in a constant |
12:24:06 | FromDiscord | <Hourglass [She/Her]> So it's `const LOOKUP = {"varint": "int32", ...}` |
12:24:40 | FromDiscord | <Hourglass [She/Her]> I need to use it as a constant for macro stuff, and I'm pretty sure `Table`s don't work at compile time when i tried it |
12:32:16 | FromDiscord | <Hourglass [She/Her]> Nvm seems like `Table`s do work at compile time, it was my bad code last time |
12:32:44 | FromDiscord | <Phil> Yeah, I've used tables at compiletime plenty of times |
12:34:52 | FromDiscord | <Hourglass [She/Her]> Joy, I need to implement bitfield support |
12:36:20 | FromDiscord | <Hourglass [She/Her]> What is the `void` type? |
12:42:07 | PMunch | Wait, @ringabout is planety? |
12:42:14 | FromDiscord | <demotomohiro> It means procedures dont return a value |
12:46:07 | * | derpydoo quit (Ping timeout: 252 seconds) |
12:47:12 | FromDiscord | <System64 ~ Flandre Scarlet> Hi, is it possible to overload an operator? if yes, how? |
12:47:30 | FromDiscord | <Hourglass [She/Her]> In reply to @demotomohiro "It means procedures dont": I'm assuming that's implicit then |
12:48:31 | FromDiscord | <Phil> In reply to @System64 "Hi, is it possible": Depends, is it an operator that is not yet defined? |
12:48:38 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4oDK |
12:48:59 | FromDiscord | <Hourglass [She/Her]> Should work for all operators defined in Nim, as long as it doesn't conflict with another proc |
12:49:05 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Isofruit "Depends, is it an": No, the + operator as Hourglass said |
12:49:38 | FromDiscord | <Hourglass [She/Her]> What I posted should work, just make sure you use backticks |
12:50:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4oDM |
12:51:04 | FromDiscord | <Yepoleb> In reply to @PMunch "Wait, <@658563905425244160> is planety?": Yes |
12:51:28 | FromDiscord | <Phil> Given we have planetis rolling around that is super confusing |
12:51:42 | FromDiscord | <Phil> I thought planetis was the original owner and ringabout took over maintenance |
12:52:38 | FromDiscord | <sOkam!> In reply to @PMunch "sOkam, there seems to": flags don't change the filename that is being output by gcc |
12:52:58 | FromDiscord | <sOkam!> (edit) "gcc" => "nimc/gcc" |
12:53:44 | FromDiscord | <sOkam!> they come from different folders, so should be named as such to avoid clashes, but they aren't so the linker just gets confused |
12:56:57 | FromDiscord | <sOkam!> is there a way to convert a `cstring` to a `clong`?↵basically the C code expects an `intptr_t`, which is a clong, but the function wrapped returns a `char` which I was mapping as a cstring↵but now I realize that the pointer needs to be converted to clong, because the interface only works with ints 🤔 |
12:57:20 | FromDiscord | <sOkam!> (edit) "is there a way to convert a `cstring` to a `clong`?↵basically the C code ... expects" added "I'm wrapping" |
12:57:42 | FromDiscord | <Hourglass [She/Her]> What'd be the best way to represent bitfields in Nim? |
12:58:03 | FromDiscord | <sOkam!> can i just `cast[clong](theCString)` and call it a day, or is that going to crash? |
12:58:11 | PMunch | This explains where @ringabout came from. I thought it was a bit strange that someone I had never heard of suddenly where contributing good stuff to the Nim compiler :P |
12:58:57 | PMunch | sOkam, uhm, why do you expect that to work? |
12:59:04 | PMunch | A clong? |
12:59:10 | FromDiscord | <sOkam!> clong is just an int |
12:59:26 | PMunch | I know |
12:59:30 | FromDiscord | <ringabout> Yeah, @PMunch btw how is the Mod team going? |
12:59:42 | FromDiscord | <sOkam!> the closest int similar to intptr_t, so i figured that if i can get the address casted to clong it should work, but don't know how |
13:00:06 | PMunch | I mean you should probably do `myCstr.addr.clong` or something. Might need a cast, not sure if addr can be converted to an integer |
13:00:29 | FromDiscord | <ringabout> In reply to @Isofruit "I thought planetis was": Lol, just coincidence |
13:00:30 | FromDiscord | <sOkam!> kk |
13:00:40 | PMunch | @ringabout, going good. Just recently added @Yepoleb as a moderator, and we're looking into adding more people |
13:01:12 | PMunch | And of course we got the Matrix anti-spam measures up and running, which has improved the spam situation *a lot* |
13:01:29 | FromDiscord | <Phil> Nice! |
13:02:13 | FromDiscord | <ringabout> In reply to @PMunch "<@658563905425244160>, going good. Just": Great! |
13:08:26 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4oDU |
13:08:35 | FromDiscord | <sOkam!> (edit) |
13:14:15 | FromDiscord | <ringabout> Use procs if you have to use addrs. |
13:15:44 | FromDiscord | <sOkam!> wouldn't a proc return the local address of the string inside the proc? |
13:16:05 | FromDiscord | <sOkam!> or is it going to know that the original address is what needs to be returned? |
13:17:55 | FromDiscord | <demotomohiro> How about to `proc caddr(str: var cstring): clong = cast[clong](str.unsafeAddr)`? |
13:18:27 | FromDiscord | <sOkam!> `nimpretty thefile.nim` 🤷♂️ |
14:24:07 | PMunch | Looked around for inspiration for what to name my logging library. Which led me to the Norwegian Wikipedia article on logging (like felling trees). These illustrations are magnificent: https://no.wikipedia.org/wiki/Trefelling |
14:28:38 | FromDiscord | <auxym> is that the old school MS Paint spray tool? 😄 |
14:29:39 | FromDiscord | <Rika> wtf is that illustration lmfaop\ |
14:29:41 | FromDiscord | <Rika> (edit) "lmfaop\" => "lmfao" |
14:31:13 | PMunch | Yup, it's basically an MS Paint illustration of how to fell a tree :P |
14:42:21 | FromDiscord | <auxym> memories of usig win95 when I was 8yo, lol |
14:45:22 | FromDiscord | <Gumbercules> Windows still has paint you know... |
14:47:21 | * | peterhil quit (Quit: WeeChat 3.8) |
14:49:11 | PMunch | But who still uses Windows, haven't you heard it's the year of Linux on desktops :P |
14:57:45 | NimEventer | New thread by Nlits: Using nimble as a library, see https://forum.nim-lang.org/t/9916 |
14:59:41 | PMunch | It's so great to have NimEventer back :) |
15:08:55 | * | PMunch quit (Quit: Leaving) |
15:24:43 | FromDiscord | <ringabout> In reply to @NimEventer "New thread by Nlits:": @Phil, your chance, haha |
15:24:50 | FromDiscord | <ringabout> (edit) "@Phil," => "@Phil hil," |
15:24:58 | FromDiscord | <ringabout> (edit) "hil," => "" |
15:27:17 | * | sagax joined #nim |
15:29:50 | * | arkurious joined #nim |
15:46:50 | * | kenran quit (Remote host closed the connection) |
15:59:10 | FromDiscord | <Phil> I was born for this moment! |
16:00:59 | FromDiscord | <ringabout> Precisely, it must be fate |
16:09:08 | FromDiscord | <enthus1ast> @Phil\: ^ |
16:10:20 | FromDiscord | <ringabout> Is this only me or messages are lost? |
16:10:50 | FromDiscord | <ringabout> https://media.discordapp.net/attachments/371759389889003532/1077261053592866857/image.png |
16:11:04 | FromDiscord | <enthus1ast> https://github.com/PMunch/nimbleutils |
16:11:23 | FromDiscord | <ringabout> image.png https://media.discordapp.net/attachments/371759389889003532/1077261194097852488/image.png |
16:12:02 | * | azimut quit (Ping timeout: 255 seconds) |
16:12:21 | FromDiscord | <Phil> Yeah that was dropped, I thought enthus1ast 's post was kind of a "this" thing instead of recommendation of anything |
16:22:12 | NimEventer | New thread by pietroppeter: Nim birthday?, see https://forum.nim-lang.org/t/9917 |
16:39:09 | FromDiscord | <Coachonko> Is it correct to export a proc like so `proc name()`? I keep writing `proc name()` instead |
16:39:37 | FromDiscord | <Phil> Yeah, ` proc name()` is correct. |
16:40:02 | FromDiscord | <Phil> If it's easier for you `export name` is also an option. Could work if you make a habit of putting that stuff at the bottom of the file or sth |
16:41:00 | FromDiscord | <Coachonko> `` is concise but am dyslexic |
16:41:20 | FromDiscord | <Coachonko> Maybe I should use `export name` instead |
16:41:31 | FromDiscord | <Coachonko> Thanks for the tip |
16:41:37 | FromDiscord | <Phil> Happy to help |
16:55:18 | * | xet7 joined #nim |
17:09:28 | FromDiscord | <tsoj> Does anybody know if the httpclient and/or net module are threadsafe? |
17:19:51 | FromDiscord | <planetis> default vs zeroDefault, what's the difference? I suppose the last ignores default values for object fields right? |
17:19:54 | FromDiscord | <planetis> Also do they both call destroy? |
17:20:58 | FromDiscord | <planetis> In reply to @planetis "Also do they both": yep they do |
17:21:41 | FromDiscord | <Phil> planetis |
17:22:25 | FromDiscord | <Phil> Your name and the fact that "planety" exists as a name of significance in the nim ecosystem were intensely confusing, just wanted you to know 😛 |
17:22:58 | * | arkurious quit (Ping timeout: 246 seconds) |
17:25:29 | FromDiscord | <planetis> In reply to @Isofruit "Your name and the": yes I agree but it's not my fault so I can't do anything |
17:35:25 | * | arkurious joined #nim |
17:45:00 | FromDiscord | <Ecorous> Finally got round to submitting a PR |
17:45:19 | FromDiscord | <Ecorous> For the `getDataDir` |
17:45:20 | FromDiscord | <Ecorous> https://github.com/nim-lang/Nim/pull/21408 |
17:45:52 | FromDiscord | <Phil> Sweet! |
17:46:38 | FromDiscord | <Phil> In reply to @Ecorous "Finally got round to": No tests though? |
18:10:14 | FromDiscord | <demotomohiro> How to test `getDataDir`? The return value depends on OS, user name or env var. |
18:13:39 | FromDiscord | <Ecorous> In reply to @Isofruit "No tests though?": I wasn't sure how to do a test, but I have tested it |
18:14:26 | FromDiscord | <Phil> That is a good point, I guess my reflexes just kicked in that you should test everything that hasn't escaped to the trees on the count of three |
18:14:52 | FromDiscord | <Phil> I guess you could spin up a container and see if the result in each container is as expected? |
18:16:26 | FromDiscord | <Ecorous> I could do |
18:16:38 | FromDiscord | <Ecorous> I also got a friend to test it on windows |
18:24:55 | * | arkurious quit (Ping timeout: 246 seconds) |
18:37:35 | * | arkurious joined #nim |
18:58:05 | FromDiscord | <turbo> I've got an odd problem of a _segfault at runtime_ caused by a type declaration, but _only_ if that type is declared inside a proc (or any number of procs deep). Fine at module root. Here's the code (tested on macOS with Nim 2): https://gist.github.com/turbo/8d0101656d23e64078782233a7608154 |
18:59:21 | FromDiscord | <turbo> (`c` backend) |
19:02:15 | FromDiscord | <turbo> Also happens with 1.6.10, please tell me I'm missing something glaringly obvious |
19:04:46 | FromDiscord | <demotomohiro> Maybe `VF` is larger than stack size and cause stack overflaw. |
19:04:52 | FromDiscord | <turbo> Ah, it depends on `V_AX`, for e.g. 1000 it succeeds, so you may be right |
19:07:16 | FromDiscord | <demotomohiro> Variables outside of procs dont use stack so they doesnt cause stack overflow. |
19:09:33 | FromDiscord | <demotomohiro> If you need large array only inside a proc, use `seq`, `ref array` or `ref object` contains array.↵They are allocated on heap and you can use larger memory than stack. |
19:11:14 | * | derpydoo joined #nim |
19:11:27 | FromDiscord | <turbo> Thanks, yes seq->array seems to solve it |
19:37:02 | * | jmdaemon joined #nim |
19:49:50 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
19:51:51 | FromDiscord | <Nerve> Is there any built-in equivalent to Python's chained comparisons, e.g. `0.0 <= x < 1.0`? |
20:00:45 | FromDiscord | <demotomohiro> !eval let x = 0.5; echo x in 0.0 .. 1.0 |
20:00:53 | NimBot | true |
20:18:15 | * | ehmry joined #nim |
20:18:17 | * | ehmry quit (Client Quit) |
20:18:37 | * | ehmry joined #nim |
20:19:03 | * | Notxor joined #nim |
20:25:31 | NimEventer | New Nimble package! nemini - Nemini is a very basic Gemini server able to host static files and with virtual host support, see https://codeberg.org/pswilde/Nemini |
20:30:41 | NimEventer | New thread by demetera: Save audio stream to the file from httpstream, see https://forum.nim-lang.org/t/9918 |
21:24:40 | FromDiscord | <eyes> Okay maybe I'm just looking up the wrong words but I cannot figure out how to get a reference to something in nim |
21:24:44 | FromDiscord | <eyes> ptr or ref |
21:25:21 | FromDiscord | <eyes> like uhhh heres an example |
21:27:19 | FromDiscord | <eyes> sent a code paste, see https://play.nim-lang.org/#ix=4oIA |
21:27:34 | FromDiscord | <eyes> how can I call ``changeThingTo20`` on one of the ``Thing``s inside of ``things`` |
21:28:08 | FromDiscord | <eyes> im actually not sure if this code compiles because i wrote it in discord lol |
21:29:48 | FromDiscord | <eyes> dammit no it doesnt because you cant store a ref object like that |
21:30:14 | FromDiscord | <eyes> okay whatever you get what i mean though I hope? pass an element of a seq or array or other data structure by reference |
21:30:30 | FromDiscord | <eyes> I could pass the data structure + the address of the thing within it instead I guess |
21:30:36 | FromDiscord | <Diogenes of Toronto> Would it be ref of object, |
21:34:01 | FromDiscord | <eyes> I'm not sure what you mean |
21:34:42 | FromDiscord | <Diogenes of Toronto> You are referencing a sequence. Thing is not a reference |
21:35:51 | FromDiscord | <Elegantbeef> You cannot take a ref of something |
21:35:55 | FromDiscord | <Elegantbeef> What you want is `var Thing` |
21:36:02 | FromDiscord | <Elegantbeef> in Nim a `ref` is a heap allocated reference counted type |
21:36:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oIB |
21:37:17 | FromDiscord | <Diogenes of Toronto> ref is a pointer right? |
21:37:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oIC |
21:37:27 | FromDiscord | <Elegantbeef> Ref is a heap allocated memory safe pointer yes |
21:37:36 | FromDiscord | <Diogenes of Toronto> Okay |
21:37:52 | FromDiscord | <Elegantbeef> `ptr T` is the equivlent to a C `T` and `pointer` to C's `void` |
21:38:06 | FromDiscord | <Elegantbeef> Those are unsafe pointers and can be stack allocated |
21:38:09 | FromDiscord | <Diogenes of Toronto> Okay |
21:38:12 | FromDiscord | <Elegantbeef> Generally one uses `var` instead of those |
21:39:02 | FromDiscord | <Elegantbeef> One should use `ref` when they want reference semantics |
21:39:15 | FromDiscord | <Elegantbeef> https://internet-of-tomohiro.netlify.app/nim/faq.en.html#type-when-to-use-ref-object-vs-plain-object-qmark |
21:41:55 | FromDiscord | <Diogenes of Toronto> So how do I dereference an object ref that isn't a type? |
21:42:13 | FromDiscord | <Elegantbeef> `[]` is the dereference operator |
21:42:36 | FromDiscord | <Diogenes of Toronto> Okay |
21:43:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oID |
21:43:09 | FromDiscord | <Diogenes of Toronto> Cool |
21:43:51 | FromDiscord | <Diogenes of Toronto> This makes things easier as a go dev |
21:44:19 | FromDiscord | <Elegantbeef> Yea, unlike Go nim doesnt automatically convert things to references |
21:44:21 | FromDiscord | <Elegantbeef> It's more explicit and clear |
21:45:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4oIE |
22:04:58 | * | dropkick joined #nim |
22:07:57 | FromDiscord | <Ecorous> Anyone know why the CI fails on my PR?↵↵https://github.com/nim-lang/Nim/pull/21408 |
22:09:22 | NimEventer | New thread by tsojtsoj: Are the modules httpclient/net threadsafe?, see https://forum.nim-lang.org/t/9919 |
22:10:14 | FromDiscord | <Elegantbeef> Might just be flaky, close and reopen the PR to restart the CI |
22:10:59 | FromDiscord | <Ecorous> Alright |
22:16:28 | FromDiscord | <demotomohiro> @Ecorous It seems you have created that pull request without creating branch. I recommend creating a branch like `git checkout -b add-getdatadir` before makig change next time you send PR. |
22:42:59 | * | Notxor quit (Quit: Leaving) |
22:53:32 | FromDiscord | <Hourglass [She/Her]> I really dislike the protocol.json files but if I want to cut out 99% of the future work, I need to work on parsing it sigh |
22:54:53 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4oJQ |
22:57:06 | FromDiscord | <Hourglass [She/Her]> And I'm not really sure about how to do it |
22:57:57 | * | xet7 quit (Quit: Leaving) |
23:23:26 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/parsejson.html |
23:26:06 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4oJZ |
23:41:09 | FromDiscord | <Hourglass [She/Her]> In reply to @demotomohiro "Do you want to": Yep, not sure how to go about it tho |
23:42:13 | * | mahlon quit (Remote host closed the connection) |
23:43:50 | * | mahlon joined #nim |
23:44:03 | FromDiscord | <Hourglass [She/Her]> I'm obviously gonna need to use macro hell but |
23:44:29 | FromDiscord | <demotomohiro> You can read a file with `staticRead`. If json module works at compile, you can parse json file in macro. |
23:46:09 | FromDiscord | <Hourglass [She/Her]> It should, but even if it doesn't, I could use a compile block right? |
23:46:34 | FromDiscord | <Hourglass [She/Her]> But it's more of an issue of "how do i parse this and turn it something useful" |
23:46:51 | FromDiscord | <huantian> macros! probably |
23:53:00 | FromDiscord | <Hourglass [She/Her]> I mean yeah :p |
23:53:06 | FromDiscord | <Hourglass [She/Her]> But the format is atrocious lmao |
23:57:14 | FromDiscord | <Hourglass [She/Her]> Maybe I'm overcomplicating this too much |
23:58:32 | FromDiscord | <auxym> that's what futhark does IIRC. parse a json at CT and with a macro generate a bunch of procs and types |
23:58:53 | FromDiscord | <Hourglass [She/Her]> I'm stressing over how i want it to look as opposed to the actual generation, I can spend time making it all pretty after a working product |