00:00:15 | FromDiscord | <emanresu3> Nevermind, I was using Nim 1.4.8, I updated to Nim 1.6.6 and it's working! |
00:06:52 | FromDiscord | <pietroppeter> In reply to @Elegantbeef "Oh cool, that code": ok updated issue, thanks! ❤️ |
00:22:46 | FromDiscord | <Elegantbeef> Though i should be very clear it's pretty much a toy ECS, so no clue if it's worthwhile |
00:29:26 | FromDiscord | <pietroppeter> well, my goal was toying around with ecs, so I'd say it fits the bill 🙂 |
00:48:36 | FromDiscord | <scarf> how do i pass multiple arguments when `createThread`? |
00:49:16 | FromDiscord | <scarf> (edit) "how do i" => "what is an idiomatic way to" |
00:49:21 | FromDiscord | <scarf> (edit) "when" => "with" |
00:49:39 | FromDiscord | <Elegantbeef> A tuple |
00:52:40 | FromDiscord | <scarf> sent a code paste, see https://play.nim-lang.org/#ix=4fVy |
00:53:36 | FromDiscord | <Rika> No no, you have normal arguments in the function (not a tuple) then you pass a tuple of arguments as if it was the function call |
00:53:46 | FromDiscord | <Rika> Wait |
00:53:47 | FromDiscord | <Rika> No |
00:53:52 | FromDiscord | <Rika> That’s a different language |
00:53:52 | FromDiscord | <Rika> Lol |
00:53:58 | FromDiscord | <Rika> Me forgetful |
00:54:03 | FromDiscord | <Rika> What’s the problem exactly then? |
00:54:32 | FromDiscord | <scarf> i want to use `threadFunc` with multiple arguments inside `createThread` in a meaningful way |
00:54:45 | FromDiscord | <Rika> I think the thread type in the array up top is wrong |
00:55:26 | FromDiscord | <Elegantbeef> It is |
00:55:31 | FromDiscord | <Rika> Put the argument type before the variables and do Thread[Args] no? |
00:55:49 | FromDiscord | <scarf> pardon? |
00:56:14 | FromDiscord | <scarf> what i just want to do is to follow examples in <https://nim-lang.org/docs/threads.html#examples> but also print thread id in `threadFunc` |
00:56:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fVA |
00:56:42 | FromDiscord | <Rika> The type you pass into the thread type is the same type of the parameter of the function |
00:56:47 | FromDiscord | <Rika> (edit) "parameter" => "argument" |
00:57:06 | FromDiscord | <Rika> Is -> should be |
00:58:37 | FromDiscord | <scarf> thanks, it works now |
01:00:01 | FromDiscord | <Rika> 👌 |
01:00:32 | FromDiscord | <scarf> sent a code paste, see https://play.nim-lang.org/#ix=4fVE |
01:01:20 | FromDiscord | <ChocolettePalette> What is it then? O.O |
01:01:43 | FromDiscord | <Elegantbeef> Destructors have to be defined in the same file as the object declaration |
01:02:43 | FromDiscord | <ChocolettePalette> Since when does nim have destructors? 0\_0 |
01:03:47 | FromDiscord | <Elegantbeef> Since like 1.2 |
01:03:50 | FromDiscord | <Elegantbeef> Arc/Orc use them |
01:05:13 | FromDiscord | <scarf> In reply to @Elegantbeef "Destructors have to be": putting it inside `lib/core/locks.nim` also fails :( |
01:06:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fVF |
01:07:17 | FromDiscord | <scarf> wonder why it doesn't work for just `Lock` tho? |
01:08:15 | * | yarrie quit (Quit: Leaving) |
01:08:25 | FromDiscord | <Elegantbeef> Are you sure you got the same error? |
01:08:39 | FromDiscord | <Elegantbeef> If you declared it in the file after declaration and before usage it should work |
01:17:44 | FromDiscord | <Elegantbeef> Eitherway eventually Nim's threading primitives will be fine |
01:18:09 | FromDiscord | <ChocolettePalette> Eventually... |
01:19:39 | FromDiscord | <ringabout> In reply to @scarf "hecc, I thought Lock": Did you use `Lock = object`? |
01:20:09 | FromDiscord | <Elegantbeef> Eh 2.0 is soon |
01:20:54 | FromDiscord | <ringabout> std/threads will get rid of generics and use pointers instead. |
01:24:36 | FromDiscord | <ringabout> Lock is a alias to sysLock, so you cannot define destructors for it. |
01:24:42 | FromDiscord | <ringabout> (edit) "a" => "an" |
01:25:58 | FromDiscord | <ringabout> You need to wrap SysLock in the new Lock object. |
01:28:31 | FromDiscord | <scarf> In reply to @Elegantbeef "If you declared it": alright, will try again after going back home |
01:28:31 | FromDiscord | <scarf> In reply to @ringabout "Did you use `Lock": i used `Lock` in `std/locks` |
01:28:33 | FromDiscord | <scarf> In reply to @ringabout "Lock is an alias": thanks, that was the reason. would it be feasible to define destructor for syslocks? |
01:28:33 | FromDiscord | <scarf> alright, that'd require some tweaking, i guess |
01:29:52 | FromDiscord | <ringabout> See also https://github.com/nim-lang/Nim/pull/18640/files |
01:30:03 | FromDiscord | <ringabout> It is not necessarily correct though. |
01:32:57 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
01:50:31 | FromDiscord | <banan|crab> how do i get the root directory in nim |
02:21:50 | FromDiscord | <ChocolettePalette> Idk if you can do it in Nim but in C++ yoh can do e.g. `std::string root = "/";`↵(@banan|crab) |
02:22:05 | * | arkurious quit (Quit: Leaving) |
02:22:09 | FromDiscord | <Elegantbeef> You can of course do the same but that's not platform agnostic |
02:22:32 | FromDiscord | <ChocolettePalette> Well it works on android too |
02:23:22 | FromDiscord | <Elegantbeef> It works on \nix |
02:24:53 | FromDiscord | <ChocolettePalette> Linux ends with nux so it actually works on \n?x |
02:26:01 | FromDiscord | <Elegantbeef> Sorry i cannot spell that's the same as nix to me |
02:26:03 | FromDiscord | <scarf> In reply to @ringabout "See also https://github.com/nim-lang/Nim/pull/18640": oh, it was already proposed, nice. |
03:00:40 | FromDiscord | <banan|crab> In reply to @ChocolettePalette "Idk if you can": will it work on windows |
03:00:58 | FromDiscord | <Rika> No lol |
03:04:17 | FromDiscord | <banan|crab> rip |
03:04:55 | FromDiscord | <ChocolettePalette> sent a code paste, see https://play.nim-lang.org/#ix=4fVP |
03:05:28 | FromDiscord | <banan|crab> but in nim tho |
03:05:50 | FromDiscord | <ChocolettePalette> ACTUALLY↵(@banan|crab) |
03:06:00 | FromDiscord | <ChocolettePalette> I will give you an answer |
03:06:13 | FromDiscord | <banan|crab> thanks |
03:08:16 | FromDiscord | <ChocolettePalette> Idk if you have a "root" on windows, afaik you have several disks thereE.g. your program can reside on a disk D\:/ or smthSo if you want to get the root directory of your disk, you can simply move to the parent "../" directory until there's no more parent directory |
03:10:15 | FromDiscord | <ChocolettePalette> Here are the docs\:https://nim-lang.org/docs/os.html#setCurrentDir,stringAnd since this module is cross platform it will work on windows |
03:31:19 | FromDiscord | <rem ig> what parsing frameworks are there |
03:31:54 | FromDiscord | <rem ig> i'll just go back to this language because attempting to rewrite it in haskell made my brain hurt |
03:32:26 | FromDiscord | <rem ig> but i don't want to do recursive descent |
03:32:51 | FromDiscord | <rem ig> (edit) removed "but" |
03:33:01 | FromDiscord | <rem ig> (edit) "what parsing frameworks are there ... " added "(not combinators)" |
03:34:25 | FromDiscord | <rem ig> something like antlr or lark |
05:31:55 | FromDiscord | <Tuatarian> Why does `r[0]` for accessing the first thing in a `Slice[Natural]` not work? |
05:31:57 | FromDiscord | <Tuatarian> how should I do it instead? |
05:32:28 | FromDiscord | <albassort> ??? |
05:32:53 | FromDiscord | <Elegantbeef> `r.a` |
05:33:13 | FromDiscord | <albassort> but shouldn't slices work on 0? |
05:33:21 | FromDiscord | <Elegantbeef> What? |
05:35:38 | FromDiscord | <albassort> "abc"[0 .. 1] == "ab" |
05:36:12 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "`r.a`": thanks |
05:39:56 | FromDiscord | <rem ig> is npeg fast enough to use |
05:40:05 | FromDiscord | <rem ig> i thought PEG were slow |
05:41:39 | FromDiscord | <Rika> In reply to @albassort ""abc"[0 .. 1] ==": That’s not what they’re asking |
05:43:10 | FromDiscord | <albassort> yea im confused as to what they're saying? |
05:43:49 | FromDiscord | <Rika> “Why can’t I index a slice? `0..1[0]` doesn’t work” |
05:44:40 | FromDiscord | <albassort> ah |
05:45:17 | FromDiscord | <albassort> theres no "count leading 1s" in bitops |
05:45:28 | FromDiscord | <Rika> Not relevant |
05:45:48 | FromDiscord | <albassort> its relevant for me |
05:45:55 | FromDiscord | <Rika> Oh do you mean another topic |
05:46:07 | FromDiscord | <Rika> Invert the integer and CLZ then |
05:46:15 | FromDiscord | <Rika> Bitwise not |
05:46:48 | FromDiscord | <albassort> yea but thats like 12 extra cycles I could be doing something else >:O |
05:47:00 | FromDiscord | <Rika> Yeah okay |
05:47:20 | FromDiscord | <Rika> Go design the processor with the CLO operation then lol |
05:47:54 | FromDiscord | <Elegantbeef> It expands to native code↵(@rem ig) |
05:48:49 | FromDiscord | <albassort> In reply to @Rika "Go design the processor": oh these are direct bindings |
05:48:51 | FromDiscord | <albassort> justified then |
05:49:08 | FromDiscord | <albassort> no reason to really have that low level |
05:49:16 | FromDiscord | <albassort> or high level |
05:49:39 | FromDiscord | <Rika> Think they’re as close as possible to what can be done quickly to the respective architecture you’re compiling on |
05:49:44 | FromDiscord | <Rika> Rather, for |
05:50:26 | FromDiscord | <Rika> You can always try to look for a count leading ones algorithm that’s faster than an invert bits then count leading zeroes |
06:10:06 | Zevv | @reg im: it's likely not as fast as custom written parsers, but it is pretty performant: your grammer gets compiled to Nim code at compile time, which will get compiled with your C compiler in the end. The parser inner loop is dispatched by a computedGoto when using gcc, which is pretty darn fast |
06:10:55 | FromDiscord | <Elegantbeef> @rem ig i'll ping them for you zevv 😄 |
06:11:30 | Zevv | #Nim is really done with irc, eh |
06:11:32 | Zevv | shame |
06:12:09 | FromDiscord | <Elegantbeef> Blame the freenode takeover |
06:12:52 | Zevv | one of my hobbies is avoiding propriatary services that require accounts, especially commercial services. |
06:13:21 | FromDiscord | <Elegantbeef> I'm partially with you |
06:13:25 | FromDiscord | <Elegantbeef> That's why i try to use matrix over discord |
06:13:34 | FromDiscord | <Elegantbeef> It needs an account but atleast it's not proprietary |
06:15:25 | Zevv | Life is pretty hard without google play on my phone. I had some government stuff I needed to do the other day. I told them I could not comply because I did not agree with the terms and servies of google and apple and was thus not able to run their App |
06:15:48 | Zevv | it was a fun ride to get them to send me the .apk |
06:17:07 | FromDiscord | <Elegantbeef> Atleast the EU shows some sign of want to use non proprietary software, but doesnt mean much i guess |
06:17:50 | Zevv | dutch government was planning to abandon SMS 2fa in favor of apps, but that got rolled back |
06:18:06 | Zevv | not sure if that is a good thing perse, but it shows they do care |
06:18:33 | FromDiscord | <Elegantbeef> Some german medical chat is powered by matrix, well they have a contract with element |
06:19:11 | Zevv | anyway, thanks for being my pingproxy Elegantbeef :) |
06:19:20 | FromDiscord | <Elegantbeef> The future is now |
06:20:20 | Zevv | how i learned to stop worrying and love big tech? |
06:20:31 | FromDiscord | <Elegantbeef> lol |
06:21:23 | FromDiscord | <Elegantbeef> You just need to fire the engineers so the software stops working |
06:21:28 | FromDiscord | <Elegantbeef> Follow the Musk |
06:22:40 | Zevv | we'll see. in the end everone is feel to used and do as they please; i choose not to depend on any such services, but that comes at a price. I'm a total social outcast and can't even ping discord users. |
06:23:00 | Zevv | i'll no go back to reading my paper newspaper |
06:23:24 | FromDiscord | <Elegantbeef> Just setup your own matrix home server so you then can ping a discord user instead of just using your IRC 😛 |
06:23:46 | Zevv | The fact that I *can* do that does not imply that I *want* to do that |
06:24:26 | Zevv | For me nothing changed; I just added a one line config to my IRC to drop the "FromDiscord> " prefix from every nick and everything works like before |
06:24:36 | Zevv | tadaa |
06:26:11 | Zevv | while here, I might as well go back on topic. |
06:26:39 | Zevv | What's the state of moving refs between threads these days? Can this be done sanely? |
06:27:00 | Zevv | Ara4s writeup says "Memory can be shared effectively between threads without copying in Nim version 2", but that was always possible. |
06:27:21 | Zevv | I don't want to share memory, I want to share nim-managed refs; not just share, but allocate on thread A and move the ref effectively to thread B |
06:27:24 | FromDiscord | <Elegantbeef> isolated exists, but no clue if it works yet |
06:27:47 | FromDiscord | <Elegantbeef> Channels for nim2.0 should use `isolated` so you can sink across threads, or atleast in theory |
06:28:31 | Zevv | The problem with isolate is that you can not isolate something reliably if it was not instantiated as an isolate from the start |
06:29:13 | FromDiscord | <ringabout> I don't think that's possible for now, but you should ask in the internals channel. |
06:29:41 | FromDiscord | <ringabout> Nothing changes since the last time when the question is raises in the cps matrix. |
06:29:54 | FromDiscord | <ringabout> (edit) "is raises" => "was raised" |
06:31:33 | FromDiscord | <Elegantbeef> Moving part of a graph from a thread sounds like a fun challenge 😄 |
06:32:22 | Zevv | yeah, that was my point |
06:32:39 | Zevv | I tried a number of different approaches, but they all reply on run time isolation |
06:32:59 | Zevv | and/or violate the C memory model by touching stuff outside locks |
06:33:28 | Zevv | I tend to trust mratsim on these topics, and his code still relies on raw pointers |
06:38:19 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4fWe |
06:38:24 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4fWe" => "https://play.nim-lang.org/#ix=4fWf" |
06:38:49 | FromDiscord | <Elegantbeef> was `@` too much |
06:39:12 | FromDiscord | <albassort> ? |
06:39:38 | FromDiscord | <Elegantbeef> `@x1.toOpenArrayByte(0, x1.high)` |
06:39:52 | FromDiscord | <albassort> does that cast it to a sequence? |
06:40:14 | FromDiscord | <Elegantbeef> `@` converts an open array to a sequence |
06:40:15 | FromDiscord | <Elegantbeef> It doesnt cast it |
06:40:21 | FromDiscord | <Elegantbeef> You cannot cast a slice to a sequence |
06:41:42 | FromDiscord | <albassort> In reply to @Elegantbeef "`@x1.toOpenArrayByte(0, x1.high)`": ``@(x1.toOpenArrayByte(0, x1.high))`` |
06:41:53 | FromDiscord | <Elegantbeef> Uhhh |
06:42:05 | FromDiscord | <albassort> it didn't compile with just the @ |
06:42:10 | FromDiscord | <albassort> which makes sense it did look a bit odd |
06:44:25 | * | kenran joined #nim |
06:51:22 | Zevv | @rem ig: I just checked, a straightforward NPeg json parser is about 3 times slower than the Nim-native `parseJson` parser which is used by the stdlib |
06:56:25 | * | droidrage quit (Ping timeout: 260 seconds) |
07:00:45 | * | ltriant quit (Ping timeout: 256 seconds) |
07:00:46 | NimEventer | New thread by miran: Nim 1.6.10 RC2, see https://forum.nim-lang.org/t/9614 |
07:06:43 | FromDiscord | <rem ig> In reply to @Zevv "@rem ig: I just": wow that's slow(?) |
07:31:29 | * | PMunch joined #nim |
08:36:02 | Zevv | If it's too slow, just write a parser by hand, that will aways outperform any generic generated parser. Also, it's not the parsing itself, that's running in 1/5th of the time of parsejson, but it's the string copies that take up time |
08:36:46 | FromDiscord | <Elegantbeef> Yea parseJson isnt the best metric given that it's not even the best json parser 😄 |
08:36:48 | Zevv | if nim only had true slices |
08:36:59 | FromDiscord | <Elegantbeef> Viewtypes soon TM |
08:37:13 | Zevv | soon |
08:50:38 | PMunch | A view will keep the entire original string in memory right? |
08:51:03 | PMunch | So if I load a massive JSON string and parse it, and it contains a single string, then the entire object will have to be kept in memory for that single string.. |
08:51:04 | FromDiscord | <Elegantbeef> It's a checked pointer and length |
08:51:24 | PMunch | Ah, so Nims allocator will release the surrounding data? |
08:51:33 | FromDiscord | <Elegantbeef> To be fair that's how jsony works |
08:51:40 | FromDiscord | <Elegantbeef> Jsony only works on a string it doesnt stream |
08:51:53 | FromDiscord | <Elegantbeef> But yes that's a trade off when borrowing memory |
08:52:12 | FromDiscord | <Elegantbeef> You have to ensure your borrows(parsing in this case) doesnt outlive the source |
08:52:42 | Zevv | PMunch: indeed. and the problem is that when parsing jos, one needs to make substring copies of most of the parsed elements |
08:53:18 | Zevv | a view is a checked pointer and length, and a reference to the original string, likely |
08:54:37 | Zevv | so this will make arc/orc lifes harder |
08:54:43 | Zevv | lives |
08:55:25 | PMunch | Right.. |
08:55:39 | FromDiscord | <Elegantbeef> The reference to the original string isnt needed with a borrow checker |
08:56:02 | * | ltriant joined #nim |
08:56:10 | Zevv | which we don't have :) |
08:57:29 | Zevv | for what its worth, just *parsing* 300Mb of json takes npeg 0.45 seconds. Parsing and capturing the terminals (strings, numbers, bools) bumps that up to 6 seconds. |
08:57:55 | FromDiscord | <rem ig> damn |
08:58:03 | Zevv | it's not only the string copies, its also the extra work done for capturing of course |
08:58:11 | FromDiscord | <rem ig> why does nim use 2 spaces btw? |
08:58:21 | Zevv | it doesn't |
08:58:29 | FromDiscord | <rem ig> i have to run nimpretty on my code or its unreadable sometimes |
08:58:35 | Zevv | you can use whatever number of spaces you like |
08:58:41 | Zevv | as long as you're consistent |
09:00:10 | Zevv | anyway, npeg might or might not be too slow for you use case, this is all I can squeeze out of it at this time. For 99% of the jobs I use it for it is fast enough, because I seldom need to parse hundreds of megabytes of stuff for which there does not already exist a proper parser. |
09:05:11 | FromDiscord | <rem ig> for now im just doing a recursive descent |
09:05:24 | Zevv | that's probably best |
09:05:47 | Zevv | but just out of curiosity, what is it you are parsing, do you have a reference or example? |
09:13:17 | FromDiscord | <rem ig> lua like language |
09:13:36 | FromDiscord | <rem ig> sent a code paste, see https://play.nim-lang.org/#ix=4fWO |
09:16:19 | Zevv | nice |
09:18:03 | Zevv | no left recursion in there, that should pretty much translate literally to a peg |
09:21:58 | * | dnh joined #nim |
09:27:00 | FromDiscord | <rem ig> it was a pain in the ass to design this grammar btw |
09:39:48 | Zevv | why is that? |
09:40:31 | Zevv | also, npeg can do one trick to make your life easier: it has built in pratt parser / precedence climbing |
09:40:50 | Zevv | so your term/factor/relational_expr get somewhat simpler |
09:50:00 | FromDiscord | <albassort> is there a form of table which goes between both |
09:50:16 | FromDiscord | <albassort> <-> not -> |
09:53:14 | FromDiscord | <albassort> I'll make my own i have an idea |
09:53:25 | FromDiscord | <albassort> for now I'll just invert it |
09:54:48 | Zevv | there is not, you'd typically build that with two Table[]s |
09:57:14 | FromDiscord | <albassort> indeed |
09:59:54 | FromDiscord | <albassort> how can I get a unchecked block of memory |
10:00:52 | FromDiscord | <albassort> i guess i can just use create |
10:00:54 | Zevv | how do you mean 'unchecked'? |
10:01:14 | Zevv | do you want a raw unmanaged pointer? |
10:01:15 | FromDiscord | <albassort> it just exists and nobody touches it |
10:01:16 | Zevv | like c malloc? |
10:01:26 | FromDiscord | <albassort> pretty much |
10:01:54 | Zevv | https://nim-lang.org/docs/segfaults.html#c_malloc%2Ccsize_t |
10:02:07 | Zevv | no that's wrong |
10:02:28 | Zevv | well, there is c_malloc somewhere |
10:02:47 | FromDiscord | <Yardanico> just use `create` |
10:02:55 | FromDiscord | <Yardanico> or a`alloc`, but `create` is nicer |
10:03:11 | Zevv | what he says ^ |
10:03:12 | FromDiscord | <Yardanico> it'll still use Nim's allocator, but it's a raw pointer and you need to free it yourself by calling `dealloc` |
10:03:25 | FromDiscord | <Yardanico> zevv i thought you forgot about nim altogether :P |
10:03:30 | Zevv | I mostly did |
10:03:41 | FromDiscord | <albassort> i dont think i need alloc |
10:03:43 | Zevv | it shows, I don't even know how to allocate a block of raw memory |
10:03:52 | Zevv | although it was me who reworked the nim allocater stuff a few years back |
10:03:58 | FromDiscord | <Yardanico> In reply to @albassort "i dont think i": what do you need then? |
10:04:10 | FromDiscord | <Yardanico> if you want a pointer to a block of memory, you need alloc or something abstracting it |
10:04:21 | Zevv | or just a seq[byte] and get a ptr to element #0 |
10:04:34 | FromDiscord | <Yardanico> that too |
10:06:08 | * | wallabra quit (Quit: ZNC 1.8.2 - https://znc.in) |
10:07:33 | * | wallabra joined #nim |
11:01:54 | FromDiscord | <oxnan> anyone know if I can run cpp code in nim? |
11:09:33 | Amun-Ra | you can {.compile.} it or {.emit.} it |
11:14:20 | * | Guest8738 joined #nim |
11:14:27 | * | Guest8738 quit (Client Quit) |
11:20:10 | * | jmdaemon quit (Ping timeout: 240 seconds) |
11:22:00 | PMunch | @oxnan, short answer is yes |
11:23:42 | PMunch | Hmm, again I'm stuck on multithreading again.. |
11:33:34 | PMunch | I have a bunch of IDs and a massive set of data that maps these IDs to a pair of coordinates. Now I want to run through all my data, and for each ID in my list store the coordinates. So after I'm done I should have a list of ID -> coordinate mappings. Because I have so much data I've set the parsing of it up to use threads, but now I'm struggling with how to read this list of IDs and store the results |
12:04:35 | FromDiscord | <oxnan> Amun-ra you have an example of this? |
12:17:47 | NimEventer | New thread by Hobbyman: How can I concatenate strings of type sqlQuery (db_sqlite)?, see https://forum.nim-lang.org/t/9615 |
12:20:42 | * | dnh quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
12:32:03 | Zevv | PMunch: tell me once you know how to properly do these things |
12:45:15 | PMunch | Zevv, I will.. I've been meaning to investigate this stuff for quite a while now |
12:45:29 | FromDiscord | <Phil> In reply to @oxnan "anyone know if I": I'm not 100% sure but from what I've seen the nimqml package would count as running C++ code.↵nimqml is nim bindings to qml, which is a language of QT and QT is written in C++ I think.↵Though I'm not 100% on that since I haven't invested time yet to understand how it is calling and running QT |
12:46:23 | FromDiscord | <Phil> (edit) "In reply to @oxnan "anyone know if I": I'm not 100% sure but from what I've seen the nimqml package would count as running C++ code.↵nimqml is nim bindings to ... qml,only" added "run" | "QT" => "only runs through QT's code, which" |
12:49:20 | * | dnh joined #nim |
12:53:52 | FromDiscord | <oxnan> ah nice, thanks 🙂 |
12:55:54 | FromDiscord | <ringabout> Naming is hard => https://github.com/nim-lang/Nim/pull/20850 |
12:56:40 | PMunch | Zevv, for this I ended up using a SharedTable |
12:56:57 | FromDiscord | <Phil> In reply to @ringabout "Naming is hard =>": You're telling me, I struggle with naming so damn often |
12:57:34 | FromDiscord | <Phil> I'd go with how they differ in behaviour or what the difference in their idea is, what differentiates old from new threads? |
12:57:50 | FromDiscord | <Phil> What new idea encompass the new threads? |
12:58:00 | FromDiscord | <ringabout> Look like we are on the same page. |
12:58:43 | FromDiscord | <ringabout> There are no new threads so the threads name is preserved for future use |
12:59:28 | FromDiscord | <ringabout> But the old threads module is discouraged to use since it should have been low-level primitives, not generics. |
13:00:01 | FromDiscord | <Phil> So there will be a new thread module but there is none yet? |
13:00:05 | FromDiscord | <Phil> Or will there be none at all? |
13:00:19 | FromDiscord | <ringabout> (edit) "preserved" => "reserved" |
13:00:48 | FromDiscord | <ringabout> Not for 2.0. |
13:01:02 | PMunch | Wait what? |
13:01:05 | FromDiscord | <ringabout> Perhaps 2.x with a RFC prepared |
13:01:15 | PMunch | So how are we going to use threads then? |
13:01:20 | FromDiscord | <ringabout> You can continue to use old threads |
13:01:26 | PMunch | Seems like a weird thing to cut out without any real replacement.. |
13:01:39 | FromDiscord | <ringabout> Just its name is a bit unnatural. |
13:02:07 | FromDiscord | <Phil> Can't the entire module not just have a massive deprecated pragma or sth? |
13:02:28 | FromDiscord | <Phil> Because if there's nothing to differentiate against it's a bit difficult to go with names |
13:02:40 | FromDiscord | <ringabout> There is no alternative so there is no deprecation for now. |
13:02:42 | FromDiscord | <Phil> I guess "generic-threads" would be valid since as you stated they are apparently based on generics |
13:02:57 | FromDiscord | <ringabout> The implementation of old threads module is good enough. |
13:05:57 | FromDiscord | <dlesnoff> oldthread name is already a warning, no need to add a pragma. |
13:06:46 | FromDiscord | <Phil> oldthread implicates newthread, leading to confusion when that's nowhere to be found |
13:07:06 | FromDiscord | <Phil> thus "generic-threads" remains my suggestion |
13:07:47 | * | derpydoo joined #nim |
13:18:59 | FromDiscord | <albassort> can a closure iterator take repeated input |
13:19:16 | FromDiscord | <albassort> apart from the input it is initalized upon |
13:19:18 | FromDiscord | <albassort> (edit) "initalized" => "initialized" |
13:19:29 | FromDiscord | <albassort> or will i need to do some spaghetti |
13:20:09 | FromDiscord | <dlesnoff> In reply to @Isofruit "thus "generic-threads" remains my": Ok but it should come with a flag telling that it will be deprecated/removed at some point, unless it won't |
13:21:07 | FromDiscord | <dlesnoff> oh it wasn't mentioned in the conversation, sorry so it won't. Yes generic-threads will be better then |
13:26:28 | FromDiscord | <albassort> In reply to @albassort "apart from the input": they dont, so im going to make an extra function which feeds it new data |
13:26:35 | FromDiscord | <albassort> we getting pasta-tastic |
13:27:04 | FromDiscord | <albassort> i could break it into smaller bits though and have it be less disgusting |
13:34:11 | FromDiscord | <Phil> In reply to @Jiezron "Ok but it should": Oh I entirely agree with that one |
13:34:49 | FromDiscord | <Phil> At least it should be planned on the backburner to deprecate that module the NANOSECOND an RFC is accepted for a different thread module |
13:38:08 | * | notchris joined #nim |
13:52:06 | NimEventer | New thread by choltreppe: Problems with gcc.exe and gcc.linkexe, see https://forum.nim-lang.org/t/9616 |
13:52:30 | FromDiscord | <HJarausch (HJarausch)> Nimble on Android \: tries to access nimble install https://github.com/nim-lang/bigints which isn't permitted. How to fix this? Thanks Helmut |
13:52:49 | FromDiscord | <ringabout> In reply to @HJarausch (HJarausch) "Nimble on Android \:": errors? |
13:53:59 | FromDiscord | <HJarausch (HJarausch)> Nimble on Android \: tries to access /data/local/tmp/nimble\_31638/ which isn't permitted |
13:55:47 | FromDiscord | <ringabout> https://stackoverflow.com/questions/23424602/android-permission-denied-for-data-local-tmp |
14:21:51 | FromDiscord | <HJarausch (HJarausch)> @ringabout Unfortunately this doesn't help. Even on my rooted Android tablet I cannot make /data/local accessible for a non-root user. (SE Linux). My only chance is to "convince" nimble to use a different temp folder |
14:29:06 | * | arkurious joined #nim |
14:30:02 | FromDiscord | <albassort> i dont know if this is the worst code i've ever written or the best |
14:46:31 | arkanoid | dom96: is there a reason why withTimout {.async.} returns a boolean, instead of rising an exception? Is it just a performance thing? |
14:50:01 | * | dnh quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
14:50:51 | * | dnh joined #nim |
14:55:26 | * | sagax quit (Ping timeout: 246 seconds) |
15:05:06 | FromDiscord | <scarf> In reply to @ringabout "See also https://github.com/nim-lang/Nim/pull/18640": were there any problems that caused the PR to close? |
15:06:00 | * | PMunch quit (Remote host closed the connection) |
15:07:06 | FromDiscord | <ringabout> I didn't remember, perhaps caused by lacking of reviewing. |
15:07:22 | FromDiscord | <ringabout> (edit) "didn't" => "don't" |
15:10:28 | * | Phytolizer joined #nim |
16:08:16 | * | kenran quit (Remote host closed the connection) |
16:22:04 | * | derpydoo quit (Ping timeout: 252 seconds) |
16:36:00 | Phytolizer | Would someone be interested in a bit of code review? I just yesterday finished testing an implementation of the standardized JSON patch format using the Jansson library and would like some pointers on where to go next with this package. The main implementation is around 200 LOC. https://github.com/Phytolizer/nim-jsonpatch |
16:36:36 | NimEventer | New thread by zevv: Nim 2: "Memory can be shared effectively between threads without copying in Nim version 2", see https://forum.nim-lang.org/t/9617 |
17:15:29 | FromDiscord | <vestel> Do we have smth like `shared_ptr` in Nim? |
17:16:08 | * | Phytolizer quit (Quit: Client closed) |
17:16:21 | * | Phytolizer joined #nim |
17:18:43 | NimEventer | New thread by xigoi: Nvim-summon: Neovim plugin for adding standerd library imports, see https://forum.nim-lang.org/t/9618 |
17:32:09 | FromDiscord | <Tanguy> `ref` is approximately a `shared_ptr` |
17:36:07 | * | Phytolizer quit (Quit: Client closed) |
17:36:09 | FromDiscord | <sOkam!> sent a long message, see http://ix.io/4fYg |
17:38:44 | FromDiscord | <sOkam!> etymology is seen as this esoteric theoretical-only tool... but its actually the root of all meaning. and naming is just giving meaning to ideas, so they are literally the same knowledge field, in essence |
17:39:19 | * | Phytolizer joined #nim |
17:39:23 | * | jmdaemon joined #nim |
17:40:05 | * | Phytolizer quit (Client Quit) |
17:43:13 | * | sts-q joined #nim |
17:44:01 | FromDiscord | <ShalokShalom> In reply to @sOkam! "etymology and synonym finders": We could probably write some software for this↵↵Maybe some IDE integration? |
17:44:13 | FromDiscord | <ShalokShalom> There is probably something already |
17:44:48 | * | sts-q left #nim (Reform running sic irc client says bye for now.) |
17:46:46 | NimEventer | New thread by japplegame: How to add a file to a project without importing, see https://forum.nim-lang.org/t/9619 |
17:48:28 | * | PMunch joined #nim |
17:49:13 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "I've looked at wasmtime,": Just heard about https://wasmcloud.com/ |
17:49:19 | FromDiscord | <ShalokShalom> You could be interested 🤷🏻♂️ |
17:50:50 | FromDiscord | <ShalokShalom> Hnn, crazy. That's written in Elixir. |
17:50:53 | FromDiscord | <ShalokShalom> https://github.com/wasmCloud/wasmcloud-otp |
17:53:18 | PMunch | Zevv, you around? |
17:53:58 | Zevv | sure, zup |
17:54:13 | Zevv | was my forum post stupid? |
17:54:17 | PMunch | I'm looking at your threading question |
17:54:19 | PMunch | Not at all |
17:54:29 | PMunch | I've been wondering the exact same thing! |
17:54:38 | Zevv | this issue has been hunting me for about two years |
17:54:41 | PMunch | Araq keeps saying it's super easy, but never tells us how :P |
17:54:44 | Zevv | and is one of the reasons I kidn of lost strust |
17:55:18 | Zevv | so I decided to just throw the question in the open. I have tons of details and specifics, but I chose to leave them all out |
17:55:22 | Zevv | make it an open discussion |
17:55:37 | Zevv | but imho, as long as RCs are not atomic, this can not be done |
18:00:14 | PMunch | I'm all for the open discusion |
18:00:24 | PMunch | I mean, it has to be possible to somehow move data between threads |
18:01:16 | Zevv | there's a problem with memory semantics. Say we have a magic function move() that does the job. It will need to have a sink argument |
18:01:17 | PMunch | There is the sink parameter, which makes sure that the reference isn't used after that procedure is called |
18:01:32 | Zevv | If you pass it something with RC==1, we are technically good to go |
18:01:39 | PMunch | Yup |
18:01:40 | Zevv | question is, what do you do when RC > 1 |
18:01:43 | Zevv | but ignore that for now |
18:01:56 | PMunch | I think the current implementation throws an error |
18:02:00 | Zevv | so I make code in move() that passes the ref to B somehow |
18:02:20 | Zevv | the problem is that at the end of the code of my move() fucntion nim will recrease the refs RC |
18:02:25 | Zevv | but at that time, I have already moved it to B |
18:02:30 | Zevv | so A is no longer allowed to touch that memory |
18:02:59 | Zevv | A will do this without having a proper lock on the object |
18:03:03 | Zevv | so the decrease is UB |
18:03:10 | Zevv | B might or might not see the decrease |
18:06:06 | PMunch | I think that's what isolated is for: https://github.com/nim-lang/Nim/blob/devel/lib/std/isolation.nim |
18:06:19 | Zevv | not even. isolated just makes sure RC will never be > 1 |
18:06:28 | PMunch | Ah |
18:06:29 | Zevv | but it's not a workable solution because you will need to inistantiate your object as an isolate |
18:06:34 | Zevv | and keep it around like that all the time |
18:06:43 | Zevv | the RC semantics are not different in the end |
18:07:28 | PMunch | What about this stuff? https://github.com/nim-lang/threading |
18:07:51 | Zevv | sure, you tell me |
18:09:40 | FromDiscord | <sOkam!> In reply to @ShalokShalom "We could probably write": that would be hella epic↵I guess it would be just word search integration with the IDE?↵I don't know how the word databases work, but I figure it would be just adding some sort of database navigation system, I imagine 🤔 |
18:10:29 | FromDiscord | <ShalokShalom> In reply to @PMunch "Araq keeps saying it's": This sounds like a sentence that we could frame and put on the wall 😄 |
18:10:44 | FromDiscord | <ShalokShalom> Or as stickers, for our cars 😄 |
18:11:16 | FromDiscord | <ShalokShalom> In reply to @sOkam! "that would be hella": First step would be, if any of them offer a public API |
18:11:45 | Zevv | PMunch: https://github.com/nim-lang/threading/blob/49562fa0d393e765823b2ea96ca14fbb9889a566/threading/smartptrs.nim#L78-L80 |
18:11:48 | Zevv | there you go. |
18:12:09 | Zevv | it's a re-implementation of refs, excplicitly, with atomic on the RC |
18:13:07 | * | wallabra quit (Quit: ZNC 1.8.2 - https://znc.in) |
18:13:24 | PMunch | Aah, right |
18:14:28 | FromDiscord | <sOkam!> In reply to @ShalokShalom "First step would be,": etymonline is the best database I know. and they have a chrome extension, so I figure they must have some sort of system for that 🤔 |
18:14:36 | * | wallabra joined #nim |
18:15:24 | FromDiscord | <ShalokShalom> Wonderful 😄 |
18:16:50 | PMunch | Zevv, maybe we should use Cunningham's Law and post an article about how threading works in Nim :P |
18:16:59 | PMunch | Based solely on assumptions |
18:21:16 | * | pro joined #nim |
18:26:02 | * | om3ga quit (Ping timeout: 255 seconds) |
18:33:13 | FromDiscord | <planetis> would you mind writing a simple example, it shouldn't be difficult. |
18:33:31 | Zevv | who? |
18:33:52 | FromDiscord | <planetis> Zevv, about your threading question |
18:34:12 | Zevv | well, I can write examples that don't work |
18:34:24 | FromDiscord | <planetis> sure do that |
18:34:53 | Zevv | Araq' |
18:35:02 | Zevv | s answer does not compile and is wrong in more ways |
18:35:35 | FromDiscord | <planetis> Please explain |
18:37:18 | Zevv | my question was about moving a newly allocated ref between threads. g is a global that already existed before the threas was spawned |
18:37:48 | FromDiscord | <hmmm> dumb question sirs : if I have "for i in myseq" how can I stop looping before the last element? |
18:38:09 | Zevv | also the lack of locking makes this UB, both threads might or might not agree abotu what is in `g` |
18:38:19 | Zevv | but thats' nitpicking |
18:40:43 | FromDiscord | <hmmm> I think I can use some kind of if condition + discard but seems clunky |
18:40:59 | FromDiscord | <hmmm> or pass maybe |
18:41:20 | PMunch | Zevv, how do you plan on knowing where to move something in your final code? |
18:41:42 | PMunch | I'm just curious |
18:41:55 | Zevv | let's assume a semaphore or wait cond |
18:42:27 | PMunch | Yeah but how do you know where in memory to put it? |
18:43:08 | Zevv | I can pass the address of the ref |
18:43:42 | Zevv | but that is part of the problem itself, how am I suppsed to do this so that I do not violate the memory model |
18:43:44 | PMunch | Into the thread proc as an argument? |
18:43:53 | Zevv | can this be done without 'raw' pointers in the first place? |
18:44:27 | PMunch | Well I guess channels is the "obvious" answer. But they still require copying AFAIK |
18:44:42 | Zevv | I'm fine with copying the ref itself |
18:45:06 | Zevv | but not the data, because the whole point of this excersize is to move the data, not to copy it |
18:45:25 | PMunch | Send an Isolated over a channel maybe? |
18:45:48 | Zevv | ok, let's assume that for now, these are the tools we are given |
18:46:14 | FromDiscord | <hmmm> ye if work'd but I bet there is some cute sequtils sugar I'm missing 😑 |
18:46:53 | PMunch | @hmmm, you mean break? |
18:47:17 | FromDiscord | <hmmm> nu I mean looping in a for loop x times except last one without using if |
18:47:42 | Zevv | `for` can't tell if it's the last one in all cases |
18:47:56 | FromDiscord | <hmmm> hmm I see |
18:48:00 | Zevv | for iterating seqs it might be possible, but for closure iterators there is no way to tell |
18:48:02 | PMunch | for i in myseq[0..^1] |
18:48:25 | PMunch | Oh yeah, for closure iterators all bets are off |
18:48:43 | Zevv | myseq[0..^1] will copy your seq, minus one element |
18:49:02 | FromDiscord | <hmmm> yea I think it was that one munchie 😃 |
18:49:26 | PMunch | for i in myseq.toOpenArray(0, myseq.len - 1) |
18:50:00 | PMunch | Or maybe myseq.high.. |
18:51:29 | PMunch | Zevv, so this "works" but it's ugly as sin and I'm not sure if it works: http://ix.io/4fYp |
18:53:08 | Zevv | run it on valgrind |
18:53:22 | Zevv | or asan |
19:00:34 | Zevv | nim r --passC:-fsanitize=thread --passL:-fsanitize=thread --debugger:native -d:usemalloc r.nim |
19:00:45 | * | derpydoo joined #nim |
19:02:15 | PMunch | Well that returns a slew of data race warnings |
19:02:19 | Zevv | right |
19:03:31 | PMunch | It does that if I don't touch g in the thread as well though.. |
19:03:58 | PMunch | This also shows errors, although not as many: http://ix.io/4fYt |
19:04:17 | Zevv | there are no mutexes, so it is just not going to be clean |
19:04:43 | Zevv | you can't just poke at someone elses memory and get away with it |
19:07:57 | PMunch | Trying doing it manually with a thread and not threadpool |
19:08:00 | PMunch | http://ix.io/4fYv |
19:08:24 | PMunch | Now I get fewer errors, and just as many errors whenever I access the global memory or not (2) |
19:08:44 | PMunch | It seems to actually complain that I'm accessing the thread variable.. |
19:09:38 | PMunch | I mean this should be memory safe though shouldn't it? Since I sync/join the threads before the global thread accesses g there is never actually any race going on |
19:10:38 | Zevv | seems ok |
19:17:09 | FromDiscord | <planetis> here I am sending objects from one thread to another with a spsc channel https://github.com/planetis-m/sync/blob/master/tests/tspsc1.nim |
19:17:19 | Zevv | objects or ref objects |
19:17:33 | PMunch | What's a spsc channel? |
19:17:44 | PMunch | Single-Producer, Single-Consumer? |
19:17:51 | FromDiscord | <planetis> ref. it's tested with thread sanitizer but latest allocator changes broke it |
19:18:12 | Zevv | how do you manage the arc RC? |
19:18:13 | FromDiscord | <planetis> they broke allignment, I will fill a bug report soon |
19:19:34 | FromDiscord | <planetis> just this https://github.com/planetis-m/sync/blob/master/sync/spsc_queue.nim#L49 |
19:20:15 | FromDiscord | <planetis> but note that's a special case because of trypush semantics (it's documented in the rfc) |
19:20:45 | Zevv | it's not sinking, is ti? |
19:21:14 | FromDiscord | <planetis> that one https://github.com/nim-lang/RFCs/issues/347 |
19:21:28 | FromDiscord | <planetis> ye push should sink but not trypush |
19:22:14 | FromDiscord | <planetis> here is a rc string type with isolate support https://github.com/planetis-m/cowstrings/blob/main/cowstrings.nim#L159 it makes a copy if the rc > 0 |
19:23:00 | FromDiscord | <planetis> it's tested here https://github.com/planetis-m/cowstrings/blob/main/tests/bcowstrings2.nim |
19:23:10 | FromDiscord | <planetis> but again currently broken on devel |
19:23:47 | Zevv | this is my minimal example |
19:23:56 | Zevv | ignoring the fact that there is no lock on the data in my object |
19:24:14 | Zevv | this will get complaints from the sanatizer consistenly in eqdestroy___t_64 |
19:25:35 | PMunch | This? |
19:26:05 | Zevv | hm wait the 't.addr is now' echo must go of course, that's after the move |
19:26:33 | Zevv | argh it's confusing that just using threads throws me a few data races by default |
19:26:51 | * | kenran joined #nim |
19:28:09 | FromDiscord | <planetis> I don't see any code btw |
19:28:24 | Zevv | http://ix.io/4fYz |
19:28:26 | Zevv | sorry |
19:33:26 | FromDiscord | <planetis> I don't really know if the channels_builtin works with orc we should ask araq or xflywind |
19:34:22 | FromDiscord | <planetis> I think it's deprecated for this raeson |
19:34:42 | Zevv | that's kind of the point of my question. How are we supposed to do this :) |
19:35:46 | FromDiscord | <planetis> PMunch: did you have any success with mratsim's channels? |
19:35:55 | PMunch | The ones in threading? |
19:35:56 | PMunch | Not really |
19:36:06 | FromDiscord | <planetis> no the one in weave |
19:36:23 | FromDiscord | <planetis> the one in threading is broken for sure |
19:36:38 | PMunch | I tried to apply them to Zevvs example right now, but it just gives me a vague error that "Expression cannot be isolated: t" |
19:36:45 | PMunch | Without really saying why |
19:36:46 | PMunch | Oh |
19:38:44 | FromDiscord | <planetis> that one is totally untested and shouldn't compile by design https://github.com/nim-lang/threading/blob/master/threading/channels.nim#L359 |
19:39:14 | FromDiscord | <planetis> you need to pass a var location |
19:45:48 | FromDiscord | <planetis> (for example there are other problems as well) |
20:15:00 | FromDiscord | <Bung> does the macros.`newProc` accept generic param ? |
20:29:02 | FromDiscord | <Elegantbeef> Bung no it does not |
20:29:43 | FromDiscord | <Bung> then how you do that, I know you have done before |
20:29:46 | FromDiscord | <Elegantbeef> I mean it would support typeclass'd parameters |
20:30:10 | FromDiscord | <Elegantbeef> You can call that procedure then add to the `[2]` index |
20:30:29 | FromDiscord | <Elegantbeef> https://github.com/beef331/micros/blob/master/src/micros/definitions/routines.nim#L131 |
20:31:23 | FromDiscord | <Elegantbeef> I dont have docs for Micros but it makes macros so much easier, though I assume you're doing something compiler related so it might not help you |
20:32:38 | FromDiscord | <Bung> ah, I see you modify the returned procType node by subscrition |
20:33:20 | FromDiscord | <Elegantbeef> Oh that assert is a bug waiting to happen 😄 |
20:39:29 | PMunch | @Elegantbeef, got a good title for my static-loosing issue? |
20:40:13 | FromDiscord | <Elegantbeef> "Static field access does not constant fold with arc/orc" |
20:40:30 | FromDiscord | <Bung> hmm , am debugging into this https://github.com/nim-lang/Nim/issues/16758, dunno what expected when user write a wrong macro |
20:40:42 | FromDiscord | <Bung> it lack one generic param |
20:41:38 | FromDiscord | <Elegantbeef> Well raise either an internal or local error for when it is nil |
20:43:38 | FromDiscord | <Bung> let me see how it render a invalid node |
20:44:25 | * | kenran quit (Remote host closed the connection) |
20:50:34 | FromDiscord | <Yardanico> @beef you're a professional |
20:50:59 | FromDiscord | <Yardanico> is this a bug in generic resolution or something? |
20:51:05 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4fYY |
20:51:25 | FromDiscord | <Elegantbeef> Since when?! |
20:51:29 | FromDiscord | <Yardanico> this hits recursion limit because floorDiv uses mod and for some reason the compiler picks the user-defined mod instead of the math mod |
20:51:51 | FromDiscord | <Elegantbeef> It's a generic this is correct |
20:52:05 | FromDiscord | <Elegantbeef> `floorDiv` needs `bind mod` |
20:52:21 | FromDiscord | <Yardanico> yeah |
20:52:32 | FromDiscord | <Elegantbeef> Nim forces open symbols that are overloaded in generic scope |
20:52:40 | FromDiscord | <Elegantbeef> So this is actually a rare case of "working as intended" |
20:55:19 | FromDiscord | <Elegantbeef> @ringabout\: did your change adding user defined defaults change the first node in a `nkObjConstr` to `nkType`? |
20:55:51 | FromDiscord | <Elegantbeef> I've gotta git bisect but likely somewhere around that is the issue |
20:56:05 | FromDiscord | <Bung> Error\: 'blk.p(a)' has nil child at index hmm cant get better error message for macro |
21:04:28 | arkanoid | what's the correct way to check if a float can be converted to int without losing information? |
21:06:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fZ2 |
21:07:10 | FromDiscord | <.tochka> oh nice |
21:07:14 | FromDiscord | <.tochka> needed that :D |
21:07:42 | FromDiscord | <Elegantbeef> `import std/[fenv, math]` of course |
21:08:41 | FromDiscord | <Elegantbeef> The int part is dumb now that i think about it |
21:08:50 | FromDiscord | <.tochka> do low and high work for floats btw? |
21:09:20 | FromDiscord | <Elegantbeef> It should be `f in typeof(f)(int.low)..typeof(f)(int.high)` 😄 |
21:09:26 | FromDiscord | <Elegantbeef> they return -inf and +inf |
21:09:34 | FromDiscord | <Elegantbeef> So yes/no |
21:09:54 | FromDiscord | <.tochka> hmm, not that useful |
21:11:53 | arkanoid | :-| |
21:12:57 | FromDiscord | <Elegantbeef> fenv has `maximumPositiveValue` and it's min counterpart |
21:14:20 | FromDiscord | <Elegantbeef> Yea looked into @ringabout and the defaults breaks https://play.nim-lang.org/#ix=4fZ3 seems the VM now needs to manually get the symbol for the `nkType` |
21:15:57 | * | pro quit (Quit: pro) |
21:17:52 | FromDiscord | <.tochka> is there a way to have string repr of something in buffer instead of new string allocation via std? |
21:18:16 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/digitsutils.html |
21:19:32 | FromDiscord | <Elegantbeef> You could also make your own stream like api |
21:19:37 | FromDiscord | <.tochka> so, only for ints? |
21:19:37 | FromDiscord | <Elegantbeef> frosty makes it super easy |
21:19:45 | FromDiscord | <.tochka> ik you could diy it, just asking about std |
21:20:50 | FromDiscord | <Elegantbeef> Then the answer is sadly there is no `$(var openarray[char], t: MyType)` api |
21:21:11 | FromDiscord | <Elegantbeef> I guess it'd also require a var int |
21:21:23 | PMunch | @Elegantbeef, it came out a bit wordy: https://github.com/nim-lang/Nim/issues/20854 |
21:21:25 | FromDiscord | <.tochka> for position, ye |
21:21:28 | PMunch | Feel free to add anything |
21:21:49 | FromDiscord | <Elegantbeef> You didnt even say field access once |
21:22:36 | PMunch | Was I supposed to? |
21:22:45 | FromDiscord | <Elegantbeef> Hey you asked for a title! |
21:22:51 | FromDiscord | <Arouzing> sent a code paste, see https://play.nim-lang.org/#ix=4fZ6 |
21:23:50 | FromDiscord | <Elegantbeef> remove `json.items` |
21:23:55 | FromDiscord | <Elegantbeef> It's just `items` |
21:24:20 | PMunch | And `node: volumes` won't work |
21:24:29 | FromDiscord | <.tochka> having while is kinda weird |
21:24:40 | PMunch | `volumes` is an assignment, not a type |
21:25:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fZ9 |
21:26:02 | FromDiscord | <Elegantbeef> That's a simple single depth iterator |
21:26:20 | FromDiscord | <Elegantbeef> If you want to do multi-depth you'll need to learn how to do a depth search and do that 😄 |
21:29:02 | FromDiscord | <oxnan> sent a code paste, see https://play.nim-lang.org/#ix=4fZa |
21:29:21 | FromDiscord | <Elegantbeef> `Handle(nil)` |
21:29:26 | FromDiscord | <oxnan> oh thanks |
21:29:31 | FromDiscord | <Elegantbeef> Or it might be `Handle(0)` |
21:29:41 | FromDiscord | <oxnan> thanks, will try |
21:29:51 | FromDiscord | <Elegantbeef> Handle is either a distinct pointer or a distinct integer one of those should work |
21:33:51 | FromDiscord | <Elegantbeef> @.tochka\: thinking about it there is a relatively large problem with stringifying to a preallocated buffer in that you need to either precalculate size or just add to the buffer then error when you need to overflow, so it'd be nice in some cases it almost likely will implode on you |
21:35:12 | * | PMunch quit (Quit: leaving) |
21:36:01 | FromDiscord | <.tochka> yes, but zig solves it by providing your a method to get required space for given format and arguments |
21:36:32 | FromDiscord | <.tochka> not a nim way i guess |
21:36:48 | * | om3ga joined #nim |
21:37:23 | FromDiscord | <Arouzing> sent a code paste, see https://play.nim-lang.org/#ix=4fZd |
21:37:25 | FromDiscord | <Elegantbeef> Well like i said it wouldnt be too hard to DIY using frosty 😛 |
21:37:59 | FromDiscord | <Elegantbeef> you then do `for x in myJson.filter({JInt}): echo x.intVal` |
21:38:05 | FromDiscord | <Elegantbeef> filtered\ |
21:38:23 | FromDiscord | <Arouzing> this make so much sense now!!! |
21:38:56 | FromDiscord | <.tochka> In reply to @Elegantbeef "Well like i said": i can look into it |
21:42:46 | FromDiscord | <Bung> HANDLE is int |
21:42:51 | FromDiscord | <Elegantbeef> bung use your inside voice |
21:44:16 | FromDiscord | <Bung> hmm too late |
21:46:56 | FromDiscord | <Bung> my bad it's pointer |
21:47:33 | FromDiscord | <.tochka> its whatever |
21:50:55 | FromDiscord | <oxnan> is there a way to look up an NTSTATUS code in winim easily? |
21:51:03 | FromDiscord | <oxnan> as in print the definition |
21:58:45 | FromDiscord | <.tochka> via FormatMessage and RtlNtStatusToDosError |
21:59:11 | FromDiscord | <.tochka> (edit) "via FormatMessage and RtlNtStatusToDosError ... " added "afaik" |
21:59:55 | FromDiscord | <oxnan> thanks! |
22:01:50 | arkanoid | why I get B called instead of A? https://play.nim-lang.org/#ix=4fZh |
22:04:12 | FromDiscord | <Elegantbeef> Concept matching is higher than range match |
22:04:32 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4fZj |
22:04:46 | FromDiscord | <Elegantbeef> `FloatLike` doesnt require a conversion whereas `Natural` does |
22:06:00 | arkanoid | Thanks! But why Natural requires a conversion here? |
22:06:14 | FromDiscord | <Elegantbeef> Cause int is not a natural |
22:06:24 | arkanoid | oh! range type, right |
22:06:35 | arkanoid | well, make sense |
22:06:56 | FromDiscord | <Elegantbeef> Nim chooses the most specific and an exact match is \> implicit conversion |
22:08:31 | arkanoid | I thought range types were kinda implicit, not sure why |
22:09:15 | FromDiscord | <Elegantbeef> They are implicit |
22:23:21 | FromDiscord | <oxnan> sent a code paste, see https://play.nim-lang.org/#ix=4fZn |
22:24:03 | FromDiscord | <Elegantbeef> Is it a compiler error or runtime? |
22:26:35 | FromDiscord | <oxnan> sent a code paste, see https://play.nim-lang.org/#ix=4fZp |
22:31:10 | FromDiscord | <Tuatarian> are string mixins a thing? |
22:31:21 | FromDiscord | <Tuatarian> alternatively, is there a good way to read nim code as nim code instead of as text? |
22:31:32 | FromDiscord | <Tuatarian> (edit) "alternatively, is there a good way to read nim code as nim code instead of as text? ... " added "(from a nim program)" |
22:31:58 | FromDiscord | <Tuatarian> my specific use case here is that I'd like to have a table of function definitions while minimizing the unreadability of the table itself |
22:32:00 | FromDiscord | <Tuatarian> so I |
22:33:03 | FromDiscord | <Tuatarian> I was intending to shove all the functions into some file somewhere, have a text file which lists the members of the table in a more readable manner, and read that into the actual table from the actual program |
22:34:26 | FromDiscord | <Elegantbeef> Can this be done statically? |
22:35:47 | FromDiscord | <Elegantbeef> I assume so, which means you can just make a macro generate the table then do something like `let myEventTable = genEventTable()` |
22:36:41 | FromDiscord | <.tochka> In reply to @oxnan "nothing breaks, but the": probably have to look at windows specific forums |
22:36:50 | FromDiscord | <oxnan> yeah probably |
23:31:05 | FromDiscord | <Tuatarian> In reply to @Elegantbeef "I assume so, which": ok, so I can do all the file reading and the like in a macro? |
23:31:37 | FromDiscord | <Tuatarian> I'd still need to interpret a string as nim code though |
23:31:57 | FromDiscord | <Tuatarian> this should happen statically, not just can happen statically |
23:32:42 | FromDiscord | <Elegantbeef> Why do you even need to interpret a string as nim code |
23:32:47 | FromDiscord | <Elegantbeef> Why can you not just use Nim code as nim code |
23:46:22 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4fZA |
23:46:23 | FromDiscord | <Elegantbeef> For instance |
23:47:33 | FromDiscord | <Elegantbeef> @Tuatarian |