00:02:55 | FromDiscord | <ElegantBeef> sent a code paste, see https://paste.rs/jsQ |
00:08:15 | FromDiscord | <asm95> Hi, doesn't nim has a showcase page of programs like a text editor, game, website or other application? |
00:08:40 | FromDiscord | <asm95> I found a awesome page but with just libraries like SDL bindings etc |
00:09:04 | FromDiscord | <ElegantBeef> In january we've started a `this month with nim` which shows some of that stuff |
00:09:19 | FromDiscord | <ElegantBeef> Can see them here https://nim-lang.org/blog.html |
00:09:24 | FromDiscord | <asm95> In reply to @ElegantBeef "In january we've started": Hi, but the blog doenst have a filter for those posts? |
00:09:36 | FromDiscord | <ElegantBeef> It does not |
00:09:52 | FromDiscord | <ElegantBeef> Only 3 blogs for it so far so not a big deal π |
00:10:10 | FromDiscord | <asm95> In reply to @ElegantBeef "It does not": Oh it would be nice to make a category for those posts |
00:10:18 | FromDiscord | <ElegantBeef> Well go ahead π |
00:10:41 | FromDiscord | <asm95> Don't you agree? |
00:10:53 | FromDiscord | <ElegantBeef> I just mean it's all OSS, so you can be the change you want in the world |
00:11:22 | FromDiscord | <asm95> In reply to @ElegantBeef "I just mean it's": If someone actually accepts the pull request |
00:11:48 | FromDiscord | <asm95> But thank you anyway, it was very helpful |
00:11:58 | FromDiscord | <garett> @ElegantBeef Thanks, that works great! |
00:12:08 | FromDiscord | <ElegantBeef> No problem |
00:12:33 | FromDiscord | <ElegantBeef> In reply to @asm95 "If someone actually accepts": They're generally very receptive to improvements to encourage showcase/growth |
00:16:49 | FromDiscord | <ElegantBeef> Well garret i've made an issue for it, so rest easy π |
00:18:21 | FromDiscord | <checkersai> I wanna write an ECS library but whenever I start reading about different implementations I just feel stupid |
00:19:46 | FromDiscord | <ElegantBeef> Well there are like 100 difference ECS implementations in Nim |
00:19:55 | FromDiscord | <ElegantBeef> So you have a ton of different reference material |
00:20:42 | FromDiscord | <ElegantBeef> I joke about 100 of course, but yea there are a fair bit https://github.com/search?p=1&q=ECS+language%3Anim&type=Repositories |
00:52:40 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:53:01 | * | njoseph joined #nim |
02:18:50 | * | gangstacat quit (Remote host closed the connection) |
02:29:41 | * | D__ joined #nim |
02:29:42 | * | D_ quit (Quit: π¨) |
02:35:42 | * | D__ is now known as D_ |
02:40:09 | * | D_ quit (Quit: π¨) |
02:40:55 | * | D_ joined #nim |
02:44:12 | * | D_ quit (Remote host closed the connection) |
02:44:22 | * | D_ joined #nim |
02:45:04 | * | D_ quit (Client Quit) |
02:45:26 | * | D_ joined #nim |
02:47:01 | * | gangstacat joined #nim |
03:06:08 | * | rockcavera quit (Read error: Connection reset by peer) |
03:06:35 | saem | It was likely well before my time, but at one point did Nim have a built-in debugger? |
03:06:37 | * | rockcavera joined #nim |
03:09:40 | leorize[m] | yes |
03:10:55 | saem | It still around in some form or another? |
03:11:25 | leorize[m] | I'm not sure |
03:11:36 | leorize[m] | I think it was called endb |
03:12:18 | leorize[m] | yea it's removed as of 1.0.0 |
03:12:57 | saem | damn, that's too bad. |
03:45:04 | FromDiscord | <ElegantBeef> Turns out i didnt break the tests with my change just held a broken Nim π |
03:45:25 | FromDiscord | <ElegantBeef> Though i still dont know how i feel about what i've done |
03:47:14 | saem | which change? |
03:47:28 | FromDiscord | <ElegantBeef> The case statement inference |
03:47:45 | FromDiscord | <ElegantBeef> https://github.com/nim-lang/Nim/compare/devel...beef331:sillyinfercase if you want to rate it 0-idiotic π |
03:54:44 | FromDiscord | <acek7> are there any other nim books out and about |
03:54:53 | FromDiscord | <ElegantBeef> Other than nim in action? |
03:55:48 | FromDiscord | <ElegantBeef> http://ssalewski.de/nimprogramming.html if so there is this aswell, though not printed afaik |
03:55:48 | * | spiderstew_ joined #nim |
03:56:49 | * | spiderstew quit (Ping timeout: 252 seconds) |
04:16:59 | FromDiscord | <checkersai> Isn't nim in action out of date? |
04:17:14 | FromDiscord | <checkersai> Like it was written before Nim reached 1.0 |
04:17:35 | FromDiscord | <checkersai> Also, why isn't `seq.len` a `uint`? |
04:19:37 | FromDiscord | <ElegantBeef> cause uints are scary, and no it has an errata, so it's still fine if you refer to that |
04:21:05 | FromDiscord | <checkersai> ok |
04:21:10 | FromDiscord | <checkersai> Whats so scary about uints |
04:22:55 | FromDiscord | <ElegantBeef> !eval echo 255u8 + 3u8 |
04:22:58 | NimBot | 2 |
04:23:20 | FromDiscord | <ElegantBeef> They're rather unsafe and dont prevent over/underflow |
04:39:52 | FromDiscord | <checkersai> I guess it doesn't matter for my case |
04:40:09 | FromDiscord | <checkersai> I doubt I'll need a billion entity id's |
04:41:14 | FromDiscord | <ElegantBeef> Well yea plus you dont have enough memory for that π |
04:41:28 | ForumUpdaterBot | New question by Dull Bananas: Initialize Nim array with repeated value, see https://stackoverflow.com/questions/67249832/initialize-nim-array-with-repeated-value |
04:47:19 | * | thomasross quit (Ping timeout: 268 seconds) |
05:30:42 | ForumUpdaterBot | New thread by Geekrelief: Qualify identifier with exported module?, see https://forum.nim-lang.org/t/7852 |
05:50:44 | ForumUpdaterBot | New thread by Dabod: Simulate super in Java at compile time, see https://forum.nim-lang.org/t/7853 |
06:06:24 | saem | Beef what happens when you assign to a var/let that has an explicit type within the case statement so `let b: B = left`, inside a case over `A`? |
06:06:44 | FromDiscord | <ElegantBeef> It doesnt do any reasoning there |
06:08:01 | * | Gustavo6046 quit (Ping timeout: 265 seconds) |
06:09:37 | FromDiscord | <ElegantBeef> Though i suppose it might be able to |
06:12:42 | saem | There is a reason I didn't go down this road, the inference information propagating like that breaks things. |
06:13:34 | FromDiscord | <ElegantBeef> Hey i was just toying around after making the macro i doubt this will go into the compiler |
06:15:01 | saem | You're on track to figuring it out though. |
06:15:18 | FromDiscord | <ElegantBeef> Wait this isnt a bodge?! |
06:16:06 | saem | Well the context isn't the right way to pass it along, but you are seeing the data flow regardless -- that's a good thing. |
06:16:40 | FromDiscord | <ElegantBeef> Lol, the alternative is to pass the type through all the procedures and that felt dirtier |
06:17:19 | saem | Well, there is the AST. |
06:20:38 | FromDiscord | <ElegantBeef> Considering my understanding of the compiler that doesnt mean much π |
06:24:27 | saem | I was going to say shove in nodes as a start via a new field. |
06:56:41 | FromDiscord | <ElegantBeef> Well you encouraged me to do it using an extra field on Nodes and it is now on par π |
06:56:43 | saem | @ElegantBeef: a long time ago I had a similar thought about using context. Maybe instead of shying away from caseTyp, push into it. Everytime there is any situation where narrowing information about types is available push and pop it. |
06:57:28 | FromDiscord | <ElegantBeef> I'm 100% certain anyway i approach this will be "wrong" |
06:58:02 | saem | Got a diff of the node variety? |
06:58:27 | FromDiscord | <ElegantBeef> I just added a `expected: PType` |
07:00:50 | saem | I should sleep tonight, if you want to chat about it/work on it tomorrow I'll be about. |
07:02:41 | FromDiscord | <ElegantBeef> Ok, well now it works properly afaict |
07:04:53 | FromDiscord | <ElegantBeef> https://github.com/nim-lang/Nim/compare/devel...beef331:sillyinfercase Diff if anyone else is interested π |
07:12:35 | saem | with a bit more love that generalises to cover a whole lot more situations. :D |
07:14:34 | FromDiscord | <ElegantBeef> Yea supports that `: B = left` so clearly better and smarter, i was mostly just scared of adding a value to the `PNode`, but yea i still dont know what's proper since that "this is 32 bytes on 32bit" message scares me π |
07:26:54 | saem | Yeah, same hesitation. But as the saying goes make it work, make it good, then make it fast. |
07:28:57 | saem | I think it's fine for now, by the time it's ready for PR I'm guessing it'll have changed a bunch. Seeing a working implementation is the first step. |
07:31:44 | saem | The same idea can improve other inference issues. |
07:40:21 | * | teal joined #nim |
07:42:11 | * | teal quit (Client Quit) |
07:45:37 | * | rockcavera quit (Remote host closed the connection) |
08:30:42 | FromDiscord | <madman> any idea how to set working directory in nimscript? `setCurrentDir()` is unavailable. thinking of using nake |
08:31:37 | FromDiscord | <ElegantBeef> There is a `withDir` template and also a `cd` procedure |
08:31:52 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/nimscript.html lists all the interop'd functions |
08:32:28 | FromDiscord | <madman> oh thank you |
08:32:33 | FromDiscord | <madman> i was here: https://nim-lang.org/docs/nims.html |
08:54:06 | * | natrys joined #nim |
09:15:10 | FromDiscord | <mlokis> how come this works? |
09:15:29 | FromDiscord | <mlokis> sent a code paste, see https://play.nim-lang.org/#ix=37sl |
09:15:34 | FromDiscord | <mlokis> output: |
09:15:54 | FromDiscord | <mlokis> sent a code paste, see https://paste.rs/QXq |
09:16:58 | FromDiscord | <ElegantBeef> typedesc is a generic, so in that example it only generates a procedure for float, int and string |
09:17:29 | FromDiscord | <haxscramper> `float` is `float64` |
09:17:36 | FromDiscord | <mlokis> os so each time it generates the is is increased |
09:17:44 | FromDiscord | <ElegantBeef> Well yea that's the only time it's ran |
09:17:46 | FromDiscord | <mlokis> (edit) "is" => "id" |
09:17:59 | FromDiscord | <mlokis> nice |
10:01:21 | * | clyybber joined #nim |
10:42:41 | * | fredrikhr joined #nim |
11:09:34 | FromDiscord | <zidsal> I'm seeing some weird nim behaviour in the following code?β΅https://play.nim-lang.org/#ix=37L6β΅β΅does anyone know why this doesn't compile? if I make the tuple type `TripleKindType` that code works! |
11:19:24 | FromDiscord | <haxscramper> https://wandbox.org/permlink/A8QNkqIInsRx05sM to be honest it seems like a bug with current version. devel on wandbox works correctly |
11:19:53 | FromDiscord | <haxscramper> Because `TripleKindType` is a typeclass, so your implementation should not fail the way it does not |
11:19:55 | FromDiscord | <haxscramper> (edit) "not" => "now" |
11:20:32 | FromDiscord | <haxscramper> The only thing that was wrong in your -`test(1, "name", "Bob")` instead of a `test (1, "name", "Bob")` |
11:20:48 | FromDiscord | <haxscramper> First one calls `test` with three arguments, second calls with one tuple argument |
11:21:01 | FromDiscord | <zidsal> oops, I forgot the brackets when I made my noddy example |
11:21:18 | FromDiscord | <haxscramper> But that has nothing to do with your error |
11:21:24 | FromDiscord | <zidsal> looks like switching to devel has fixed this in my actual code |
11:21:29 | FromDiscord | <zidsal> #bleedingEdge |
11:21:33 | FromDiscord | <haxscramper> are you on `1.4.4`? |
11:21:37 | FromDiscord | <haxscramper> Or 1.4.6 |
11:21:37 | FromDiscord | <zidsal> I was on 1.4.6 |
11:22:45 | FromDiscord | <zidsal> I'll just switch to devel until the next stable release, whenever that is |
11:22:52 | * | dv^_^ joined #nim |
11:23:26 | FromDiscord | <haxscramper> alternatively you can specify `[T: TripleTypeKind]` in `test` |
11:23:33 | FromDiscord | <haxscramper> And make it accent `(int, string, T)` |
11:23:53 | FromDiscord | <haxscramper> accept |
11:24:25 | FromDiscord | <zidsal> sent a code paste, see https://play.nim-lang.org/#ix=37NS |
11:25:43 | FromDiscord | <zidsal> nevermind I had a bad parameter array's just works |
12:03:20 | * | l1x joined #nim |
12:07:00 | * | sagax joined #nim |
12:12:25 | FromDiscord | <exelotl> @mlokis note that if you want your code to play nice with incremental compilation in the next Nim release, you should use the `macrocache` module instead of a compiletime variable (I believe) |
12:19:21 | ForumUpdaterBot | New Nimble package! unittest2 - unittest fork focused on parallel test execution, see https://github.com/status-im/nim-unittest2 |
12:19:44 | FromDiscord | <haxscramper> https://nim-lang.org/docs/macrocache.html#CacheCounter |
12:20:17 | FromDiscord | <haxscramper> @mlokis macrocache counter |
12:46:55 | FromDiscord | <zetashift> In reply to @ForumUpdaterBot "New Nimble package! unittest2": Doesn't testament do parallel test executions too? |
13:19:07 | FromDiscord | <mlokis> sent a code paste, see https://paste.rs/CJe |
13:19:29 | FromDiscord | <mlokis> it does not compile without pragma |
13:27:05 | FromDiscord | <haxscramper> https://play.nim-lang.org/#ix=388d |
13:27:17 | FromDiscord | <haxscramper> `const nextTypeID = CacheCounter("counter")` basically |
13:30:26 | FromDiscord | <mlokis> is there a macro that i can pass an expression and it will return its type |
13:30:46 | FromDiscord | <mlokis> (edit) "is there a macro that i can pass an expression and it will return its type ... " added "ot the expression" |
13:31:26 | ForumUpdaterBot | New Nimble package! hastysite - A small but powerful static site generator powered by HastyScribe and min, see https://hastysite.h3rald.com |
13:32:05 | FromDiscord | <mlokis> for example `1` will return `newIdentNode("int")` |
13:33:50 | ForumUpdaterBot | New thread by Masiarek2: Char type: echo ASCII code for 'space' and 'single quote', see https://forum.nim-lang.org/t/7854 |
13:37:05 | FromDiscord | <haxscramper> In reply to @mlokis "is there a macro": You need to accept `typed` argument |
13:37:30 | FromDiscord | <haxscramper> And then `getType` https://nim-lang.org/docs/macros.html#getType%2CNimNode |
13:37:46 | FromDiscord | <mlokis> i see, nice |
14:21:02 | * | PMunch joined #nim |
14:40:40 | * | rockcavera joined #nim |
15:00:34 | * | PMunch quit (Quit: leaving) |
15:17:17 | * | NimBot joined #nim |
15:22:36 | * | thomasross joined #nim |
15:31:00 | FromDiscord | <gollark> Is there something like `mktemp` available which generates a random folder under `/tmp`? `os.getTempDir()` has a bunch of warnings and also seems to only find the platform equivalent of `/tmp`. |
15:31:56 | FromDiscord | <gollark> Never mind, I checked nimble instead of just the stdlib, there is a thing for this. |
15:32:38 | FromDiscord | <flywind> there is no warnings anymore |
15:32:41 | FromDiscord | <flywind> see devel docs |
15:33:20 | * | ozzz joined #nim |
15:34:10 | FromDiscord | <flywind> eventually we will have `TempFile`, `TempDir` based on destructors. |
15:35:32 | FromDiscord | <flywind> https://nim-lang.github.io/Nim/os.html#getTempDir |
15:36:11 | FromDiscord | <flywind> and new modules |
15:36:12 | FromDiscord | <flywind> https://nim-lang.github.io/Nim/tempfiles.html |
15:36:19 | FromDiscord | <flywind> (edit) "modules" => "module" |
16:46:28 | * | Gustavo6046 joined #nim |
18:01:21 | * | sagax quit (Quit: Konversation terminated!) |
18:05:42 | FromDiscord | <aab> how to cast a pointer to a ref? |
18:07:00 | FromDiscord | <Casey.McMahon> sent a code paste, see https://paste.rs/2o9 |
18:09:49 | FromDiscord | <whisperdev> Amy I doing something wrong with chronicles? .nimble\pkgs\chronicles-0.10.1\chronicles\log_output.nim(89, 19) Error: undeclared identifier: 'Json' |
18:09:59 | FromDiscord | <whisperdev> I just import chronicles and specify sink in nim.cfg |
18:12:49 | FromDiscord | <treeform> When would use use `typed` vs `untyped` when creating a macro? What is the difference? |
18:13:40 | FromDiscord | <treeform> oh it explains it here: https://nim-lang.org/docs/tut3.html#introduction-untyped-arguments |
18:15:07 | FromDiscord | <treeform> I was fighting this bug, but it looks like it goes a way when I changed it from `typed` to `untyped`. Looks like `untyped` still gives me type information so it a win? |
18:16:09 | FromDiscord | <Solitude> sent a code paste, see https://paste.rs/FxC |
18:21:40 | FromDiscord | <haxscramper> In reply to @aab "how to cast a": You cannot safely cast a pointer to a ref and any `cast`-based operations will most likely crash instantly |
18:21:57 | FromDiscord | <Casey.McMahon> sent a code paste, see https://paste.rs/UrJ |
18:26:39 | FromDiscord | <Casey.McMahon> sent a code paste, see https://paste.rs/tQ7 |
18:29:00 | FromDiscord | <aab> sent a code paste, see https://paste.rs/vMH |
18:29:37 | FromDiscord | <haxscramper> you cannot cast `ptr` to a `ref`, they are different. `ptr` is manually managed, `ref` is GC-managed data |
18:30:07 | FromDiscord | <haxscramper> you can take `addr` for a ref, but not other way around |
18:30:13 | FromDiscord | <haxscramper> or `addr refObj[]` |
18:30:22 | FromDiscord | <Casey.McMahon> sent a code paste, see https://play.nim-lang.org/#ix=38UA |
18:31:41 | FromDiscord | <Casey.McMahon> (edit) "https://paste.rs/Omu" => "https://paste.rs/i7G" |
18:52:04 | * | Clonkk[m] quit (Ping timeout: 245 seconds) |
18:52:04 | * | guelosk[m] quit (Ping timeout: 245 seconds) |
18:52:04 | * | phatnael[m] quit (Ping timeout: 245 seconds) |
18:52:05 | * | neceve quit (Ping timeout: 245 seconds) |
18:52:17 | * | ee7[m] quit (Ping timeout: 250 seconds) |
18:52:29 | * | MTRNord quit (Ping timeout: 245 seconds) |
18:53:19 | * | guelosk[m] joined #nim |
18:53:19 | * | phatnael[m] joined #nim |
18:53:20 | * | Clonkk[m] joined #nim |
18:53:44 | * | ee7[m] joined #nim |
18:53:44 | * | neceve joined #nim |
18:57:35 | * | MTRNord joined #nim |
19:12:43 | FromDiscord | <gollark> Does anyone know where I can get help on weird SQLite issues? A query in my application was really slow when running but fine when I ran it in `sqlite3`, and I tracked it down to the query planner generating different code for a prepared statement using parameter binding versus one which just contains the value directly. |
19:13:27 | FromDiscord | <aab> In reply to @haxscramper "you *cannot* cast `ptr`": I managed to get it to work by changing ref type to a ptr type, thanks for the help |
19:21:45 | * | PMunch joined #nim |
19:28:05 | ForumUpdaterBot | New post on r/nim by tsojtsojtsoj: Nalwald: Chess engine written in Nim, see https://reddit.com/r/nim/comments/myfjx6/nalwald_chess_engine_written_in_nim/ |
19:31:14 | FromDiscord | <Solitude> In reply to @Casey.McMahon "I ended up doing": just convert i to your enum, wth |
19:34:20 | FromDiscord | <ElegantBeef> Enums are just fancy ints which means you can convert to/from easily |
19:35:11 | FromDiscord | <ElegantBeef> sent a code paste, see https://paste.rs/7Oa |
19:49:14 | FromDiscord | <gollark> Is it possible (and valid) to convert a `seq[byte]` to a `string`? asynchttpserver appears to not have any way to send `seq[byte]`s as responses, but I want to respond with a PNG. |
19:52:39 | FromDiscord | <ElegantBeef> !eval echo cast[string](cast[seq[byte]]("Hello")) |
19:52:41 | NimBot | Hello |
19:53:02 | FromDiscord | <gollark> Isn't cast unsafe? |
19:53:12 | FromDiscord | <ElegantBeef> Only unsafe if you dont wear protection |
19:53:18 | FromDiscord | <gollark> I see. |
19:53:27 | FromDiscord | <ElegantBeef> unsafe doesnt mean dont use it, it means dont use it unless you know what you're doing |
19:53:58 | FromDiscord | <ElegantBeef> I believe in this case it's completely fine since we are staying inside Nim |
19:54:04 | FromDiscord | <ElegantBeef> But i could be wrong π |
19:54:46 | FromDiscord | <treeform> In reply to @gollark "Is it possible (and": I cast string to a seq[byte] all the time. No issues so far. |
19:55:13 | FromDiscord | <gollark> I was worried because of the fact that they're apparently null-terminated, and my string isn't necessarily. |
19:55:26 | FromDiscord | <gollark> isn't necessarily free of nulls, or null-terminated |
19:55:30 | FromDiscord | <ElegantBeef> Unsafe in Nim isnt like in rust, it's not scary dont use stuff, it's "dont touch unless you know you want it" |
19:55:33 | FromDiscord | <gollark> the seq |
19:55:37 | FromDiscord | <ElegantBeef> Well Nim strings arent Cstrings |
19:55:49 | FromDiscord | <ElegantBeef> you can have a string full of `\0` |
19:56:01 | FromDiscord | <demotomohiro> string always have terminating zero but that is not count in .len() |
19:56:07 | FromDiscord | <ElegantBeef> Yea |
19:56:52 | FromDiscord | <ElegantBeef> seq's and strings have the same type layout where it's a pointer to `cap, length, data` |
19:57:18 | FromDiscord | <ElegantBeef> So the casting is fine since that extra information is in the data and only used when converted to a cstring |
19:57:48 | FromDiscord | <ElegantBeef> And treeform i've toyed with the compiler and bodged in enum inference π |
19:58:02 | FromDiscord | <ElegantBeef> still have to clean it up, but it works π |
19:59:57 | FromDiscord | <demotomohiro> Is it possible that binary layout of string or seq will be changed in future and casting them become unsafe? |
20:00:12 | FromDiscord | <ElegantBeef> Possibly, stringv2 i think does change the layout |
20:00:58 | FromDiscord | <ElegantBeef> Stores the cap and len as the first two values in the data |
20:01:08 | FromDiscord | <ElegantBeef> Atleast iirc |
20:02:11 | FromDiscord | <ElegantBeef> In that case it's still not difficult to convert |
20:04:04 | FromDiscord | <gollark> I have another problem. I need to offload the generation of the image things to another thread, since it's quite slow. It seems that just passing a tableref to `createThread` and having it update that doesn't work, since the table is presumably copied at some point. I looked at channels, but they don't look like they work well with async. What's the best way to do this? |
20:04:18 | FromDiscord | <demotomohiro> Then, casting each char to byte one by one seems safter than casting string to seq[byte] (but slower). |
20:05:19 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=39aR |
20:06:49 | FromDiscord | <gollark> I guess I could make the thing which needs the images poll a channel from the other thread and put them in a table then, but that seems terrible. |
20:11:20 | FromDiscord | <ElegantBeef> How is the program flow, does it generate image then send it out, so it only needs a single buffer for the "generating image"? |
20:11:48 | FromDiscord | <gollark> Images are generated at intervals and then may be used to respond to lots of HTTP requests. |
20:12:55 | FromDiscord | <ElegantBeef> What you could do is make a bunch of images with the data guarded by a lock then only send the data when you can acquire the lock otherwise do whatever you need to do |
20:13:17 | FromDiscord | <ElegantBeef> Dont know how that fairs with async so... π |
20:13:53 | FromDiscord | <gollark> I may just do the somewhat horrible channel thing then. |
20:14:22 | FromDiscord | <ElegantBeef> I dont do async or threading much so i'm the worst person to talk here |
20:19:48 | FromDiscord | <demotomohiro> createShared proc in system module might be able to create a object shared between threadsβ΅https://nim-lang.org/docs/system.html#createShared,typedesc |
20:20:13 | FromDiscord | <demotomohiro> but I never used it. |
20:22:21 | FromDiscord | <gollark> IIRC this has issues if the shared thing contains further GCed things. |
20:23:00 | FromDiscord | <ElegantBeef> Afaik with orc/arc since they have a shared heap you can just turn off thread analysis and do stuff that you know is safe |
20:23:47 | FromDiscord | <ElegantBeef> https://forum.nim-lang.org/t/7475 |
20:35:54 | giaco | be default "testament pattern 'tests/*.nim'" puts all the binaries next to the .nim files, is there a technical reason for this or can I avoid polluting my project dir? |
20:38:07 | FromDiscord | <ElegantBeef> You can always just gitignore all non nim/nims files in that directory so it is only local |
20:39:21 | giaco | sure, but that cleans up the repo, but not the project folder. My vscode workspace looks just messy with all the binaries |
20:54:19 | FromDiscord | <ajusa> is there any way for me to create a table that maps to multiple different types? Specifically, I'm trying to do something likeβ΅`var sorts = initTable[string, seq[any_type]]`. |
20:55:35 | FromDiscord | <ElegantBeef> You'd need to box the types using an object variant |
20:56:06 | FromDiscord | <zidsal> sent a code paste, see https://play.nim-lang.org/#ix=39ja |
20:58:43 | FromDiscord | <ElegantBeef> @ajusa something like this https://play.nim-lang.org/#ix=39jz |
21:00:12 | FromDiscord | <ElegantBeef> If the page looks dead, refresh until it's not |
21:00:27 | FromDiscord | <zidsal> it worries me how quickly you bash our these examples @ElegantBeef |
21:00:36 | FromDiscord | <ajusa> In reply to @ElegantBeef "<@!102899813149855744> something like this": Hm, that doesn't quite work for my use case it seems like. I know my table will map from string to a sequence of some type, but I don't know what type that is necessarily. |
21:01:12 | FromDiscord | <zidsal> will every type in the table map to the same value? |
21:01:21 | FromDiscord | <ElegantBeef> Well if the type cannot be statically known you might have an issue in a static language π |
21:01:38 | FromDiscord | <zidsal> same type |
21:01:46 | FromDiscord | <ajusa> In reply to @ElegantBeef "Well if the type": Yeah lol, that's the answer I was expecting to be honest. Wasn't sure if what I was asking was even feasible. |
21:01:55 | FromDiscord | <ElegantBeef> Well you can box a lot of values |
21:02:07 | FromDiscord | <ElegantBeef> But it's statically typed so you have to be able to statically represent it |
21:02:11 | FromDiscord | <zidsal> or make it take generics of a box type? |
21:02:22 | FromDiscord | <zidsal> so the box time can be defined later |
21:03:21 | FromDiscord | <ElegantBeef> Zidsal i make too many examples for some things i should just bookmark it and add commands to nimbot π |
21:03:59 | FromDiscord | <ajusa> Well, here's my use case outlined:β΅I'm working on a wrapper for a dragging/reordering library (js) for Karax. I would like the API to work by having users pass in an id (string), and a some sequence of any type. Then, when someone drags and drops something, I can look up the original sequence (using the table), and swap/move values as needed in the sequence. |
21:04:06 | FromDiscord | <zidsal> or... we put all your examples into a markov chain and hope it generates an example that a. compiles b. answers the questions |
21:04:39 | FromDiscord | <ElegantBeef> Well if this is js you can just use the `jsffi` and `JsObject` then dont have to worry about typeps |
21:04:44 | FromDiscord | <zidsal> sent a code paste, see https://play.nim-lang.org/#ix= |
21:04:44 | FromDiscord | <ElegantBeef> (edit) "typeps" => "types" |
21:04:50 | FromDiscord | <ElegantBeef> Well a JsObject |
21:04:55 | FromDiscord | <zidsal> or am I mis understanding |
21:05:20 | FromDiscord | <ElegantBeef> And a JsObject works like a jsonnode so you can always just use that ;P |
21:05:21 | FromDiscord | <ajusa> I was mimicking the way the VueJS bindings to this library work, where you basically give it a type to iterate over, and fill in a callback that has the index/item defined for each iteration |
21:05:51 | FromDiscord | <ElegantBeef> Take inspiration for the json node π https://nim-lang.org/docs/json.html#JsonNodeObj |
21:06:05 | FromDiscord | <ElegantBeef> Anyway dog's need walked, so best not need any examples! |
21:06:13 | FromDiscord | <zidsal> how do macro's work with js frontend? this could potentally work with a cachemap |
21:06:16 | FromDiscord | <zidsal> and generics |
21:06:16 | FromDiscord | <ajusa> In reply to @ElegantBeef "And a JsObject works": Yeah, JsObject might make the most sense for me here (since this code doesn't make sense to be ran on the C target) |
21:06:31 | FromDiscord | <ElegantBeef> Macros generate code the exact same |
21:06:44 | FromDiscord | <ElegantBeef> We already have jsobject to emulate the js object |
21:06:52 | FromDiscord | <ElegantBeef> You can use arbitrary fields to add to it |
21:07:12 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/jsffi.html#%5B%5D%3D%2CJsObject%2Ccstring%2CT |
21:08:08 | FromDiscord | <ajusa> Yep, so my guess is that the user just casts their `seq[my_type]` to `seq[JsObject]` before passing it into my function to add it to a global table. I'll try that and hopefully it works! |
21:14:45 | FromDiscord | <ajusa> hm, since I need to modify the seq this doesn't work as the output of cast is always immutable? So I try doing seq.add and seq.remove in my proc and I getβ΅` but expression 'things = cast[seq[JsObject]](rootTask.children)' is immutable, not 'var'` |
21:17:19 | * | aenesidemus joined #nim |
21:24:15 | * | aenesidemus quit (Quit: Leaving) |
21:25:53 | * | natrys quit (Quit: natrys) |
21:28:01 | FromDiscord | <ajusa> hm, mapping from a string to a var seq doesn't seem to work, I think that the seq is getting copied somewhere somehow? After indexing into my table, getting the seq, and modifying it the original is unchanged |
21:34:47 | * | ee7[m] quit (Ping timeout: 250 seconds) |
21:34:47 | * | neceve quit (Ping timeout: 250 seconds) |
21:34:57 | * | ee7[m] joined #nim |
21:34:57 | * | neceve joined #nim |
21:37:23 | * | fredrikhr quit (Quit: Client Disconnecting) |
21:40:01 | FromDiscord | <ajusa> seems like I need to use refs everywhere for this to work? Like passing a sequence by reference using the `ref` keyword explicitly if I want to be able to modify it from the table, rather than using `var` |
21:46:55 | FromDiscord | <ElegantBeef> @ajusa you may want to check `withValuee` |
21:46:56 | FromDiscord | <ElegantBeef> (edit) "`withValuee`" => "`withValue`" |
21:49:20 | FromDiscord | <ajusa> In reply to @ElegantBeef "<@!102899813149855744> you may want": I'm not sure if that is my problem though, as I am trying to reference something in my table that was assigned using the var type. I'll try it out though |
21:49:42 | FromDiscord | <ElegantBeef> Oh well yea it copies or sinks the value from the seq |
21:49:57 | FromDiscord | <ElegantBeef> you want it to be `ref seq[T]` if you want it to propagate backwards |
21:50:02 | FromDiscord | <ajusa> I had a minimal example, clicked publish, and then https://play.nim-lang.org/ failed lol |
21:50:21 | FromDiscord | <ajusa> In reply to @ElegantBeef "you want it to": got it, that's pretty much what I ended up going with. I |
21:50:46 | FromDiscord | <ajusa> (edit) "I" => "I'm focusing on getting this to work with my ref type first, and then I'll try making it generic afterwards π" |
21:58:53 | * | cadmium[m] joined #nim |
22:03:05 | FromDiscord | <ElegantBeef> In reply to @ajusa "I had a minimal": Yea right now ix.io is having issues, so nim playground be backed on that is having a fun issue π |
22:03:43 | * | PMunch quit (Quit: leaving) |
22:08:48 | ForumUpdaterBot | New question by Lassi: How to edit a binary at specific address locations using Nim?, see https://stackoverflow.com/questions/67258698/how-to-edit-a-binary-at-specific-address-locations-using-nim |
22:13:15 | FromDiscord | <ElegantBeef> Saem no idea if you're about but yea i now see what you mean about more intelligent inference, cause i can now solve `var t: array[4, Enum] = [valA, valB, valC, valD]` even if there is ambiguity |
22:13:27 | FromDiscord | <ElegantBeef> Which can even be extended to bytes and the like |
22:13:32 | saem | congrats! |
22:13:34 | saem | that's awesome |
22:22:06 | FromDiscord | <ElegantBeef> Thought it seems like the non enum values are more complex to remedy |
22:22:43 | giaco | is there a better way to get the fractional part of a float than "f - f.trunc"? |
22:24:38 | FromDiscord | <ElegantBeef> There is split decimal but it probably does something similar |
22:25:03 | reversem3 | How do you call a url ? var call = httpGet("https://hacker-news.firebaseio.com/v0/topstories.json") |
22:25:32 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/httpclient.html#retrieving-a-website |
22:27:09 | reversem3 | thanks i thought I had to use httpGet |
22:28:24 | giaco | thanks |
22:36:32 | reversem3 | ok so I'm getting error but because of using inim , have to remember that for next time |
22:40:12 | * | xet7 quit (Remote host closed the connection) |
22:43:25 | FromDiscord | <ElegantBeef> Yea inim probably isnt building with `-d:ssl` |
22:43:42 | FromDiscord | <ElegantBeef> You can always use treeform's puppy if you want to do requests without openssl |
22:50:49 | FromDiscord | <ajusa> sent a long message, see https://paste.rs/MTl |
22:52:01 | FromDiscord | <ElegantBeef> I know what's going here yes totally π |
22:52:42 | reversem3 | thanks , I'm just teaching my self how to parse out hacker news and hopefully build a gui for it |
23:03:20 | giaco | I'm writing a testcase for a proc that returns a float, but rounding to decimal place is not reliable (https://nim-lang.org/docs/math.html#round%2CT%2Cint) and equal operator on floats like 8.413800000001 smells like the wrong thing to do. How would you test this? |
23:04:34 | FromDiscord | <ElegantBeef> Convert to a string is my view |
23:04:43 | giaco | k |
23:04:45 | FromDiscord | <ElegantBeef> So you can remove decimals and then compare those two |
23:05:02 | FromDiscord | <ElegantBeef> https://forum.nim-lang.org/t/7850 forum post about it |
23:07:39 | giaco | thanks as always! |
23:09:30 | * | clyybber quit (Remote host closed the connection) |
23:14:14 | ForumUpdaterBot | New Nimble package! nint128 - 128-bit integers, see https://github.com/rockcavera/nim-nint128 |
23:15:24 | * | xet7 joined #nim |
23:34:05 | giaco | I've "type MyFloat = float" type with it's own "proc `$`*(f: MyFloat): string = &"{f:0.6f}"", but this makes ambiguous call when I call $ on it. The obvious solution would be to make it distinct float but that makes other function I'm using like trunc and round not working on such type. What's the correct way to borrow float functions into my distinct float? |
23:35:26 | FromDiscord | <ElegantBeef> This part of the manual explains it all https://nim-lang.org/docs/manual.html#types-distinct-type |
23:35:30 | FromDiscord | <ElegantBeef> `{.borrow.}` |
23:37:57 | giaco | yeah! |
23:38:04 | giaco | thanks again :D |
23:40:06 | FromDiscord | <ElegantBeef> Lol no problem |
23:42:36 | FromDiscord | <ElegantBeef> Trying to support `let a:[4, byte] = [255, 2, 3, 4]` without allowing `let a: uint8 = 256` be valid is odd π |
23:58:46 | * | dsrw quit (Ping timeout: 240 seconds) |