<< 25-04-2021 >>

00:02:55FromDiscord<ElegantBeef> sent a code paste, see https://paste.rs/jsQ
00:08:15FromDiscord<asm95> Hi, doesn't nim has a showcase page of programs like a text editor, game, website or other application?
00:08:40FromDiscord<asm95> I found a awesome page but with just libraries like SDL bindings etc
00:09:04FromDiscord<ElegantBeef> In january we've started a `this month with nim` which shows some of that stuff
00:09:19FromDiscord<ElegantBeef> Can see them here https://nim-lang.org/blog.html
00:09:24FromDiscord<asm95> In reply to @ElegantBeef "In january we've started": Hi, but the blog doenst have a filter for those posts?
00:09:36FromDiscord<ElegantBeef> It does not
00:09:52FromDiscord<ElegantBeef> Only 3 blogs for it so far so not a big deal πŸ˜›
00:10:10FromDiscord<asm95> In reply to @ElegantBeef "It does not": Oh it would be nice to make a category for those posts
00:10:18FromDiscord<ElegantBeef> Well go ahead πŸ˜„
00:10:41FromDiscord<asm95> Don't you agree?
00:10:53FromDiscord<ElegantBeef> I just mean it's all OSS, so you can be the change you want in the world
00:11:22FromDiscord<asm95> In reply to @ElegantBeef "I just mean it's": If someone actually accepts the pull request
00:11:48FromDiscord<asm95> But thank you anyway, it was very helpful
00:11:58FromDiscord<garett> @ElegantBeef Thanks, that works great!
00:12:08FromDiscord<ElegantBeef> No problem
00:12:33FromDiscord<ElegantBeef> In reply to @asm95 "If someone actually accepts": They're generally very receptive to improvements to encourage showcase/growth
00:16:49FromDiscord<ElegantBeef> Well garret i've made an issue for it, so rest easy πŸ˜›
00:18:21FromDiscord<checkersai> I wanna write an ECS library but whenever I start reading about different implementations I just feel stupid
00:19:46FromDiscord<ElegantBeef> Well there are like 100 difference ECS implementations in Nim
00:19:55FromDiscord<ElegantBeef> So you have a ton of different reference material
00:20:42FromDiscord<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:35saemIt 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:40leorize[m]yes
03:10:55saemIt still around in some form or another?
03:11:25leorize[m]I'm not sure
03:11:36leorize[m]I think it was called endb
03:12:18leorize[m]yea it's removed as of 1.0.0
03:12:57saemdamn, that's too bad.
03:45:04FromDiscord<ElegantBeef> Turns out i didnt break the tests with my change just held a broken Nim πŸ˜„
03:45:25FromDiscord<ElegantBeef> Though i still dont know how i feel about what i've done
03:47:14saemwhich change?
03:47:28FromDiscord<ElegantBeef> The case statement inference
03:47:45FromDiscord<ElegantBeef> https://github.com/nim-lang/Nim/compare/devel...beef331:sillyinfercase if you want to rate it 0-idiotic πŸ˜›
03:54:44FromDiscord<acek7> are there any other nim books out and about
03:54:53FromDiscord<ElegantBeef> Other than nim in action?
03:55:48FromDiscord<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:59FromDiscord<checkersai> Isn't nim in action out of date?
04:17:14FromDiscord<checkersai> Like it was written before Nim reached 1.0
04:17:35FromDiscord<checkersai> Also, why isn't `seq.len` a `uint`?
04:19:37FromDiscord<ElegantBeef> cause uints are scary, and no it has an errata, so it's still fine if you refer to that
04:21:05FromDiscord<checkersai> ok
04:21:10FromDiscord<checkersai> Whats so scary about uints
04:22:55FromDiscord<ElegantBeef> !eval echo 255u8 + 3u8
04:22:58NimBot2
04:23:20FromDiscord<ElegantBeef> They're rather unsafe and dont prevent over/underflow
04:39:52FromDiscord<checkersai> I guess it doesn't matter for my case
04:40:09FromDiscord<checkersai> I doubt I'll need a billion entity id's
04:41:14FromDiscord<ElegantBeef> Well yea plus you dont have enough memory for that πŸ˜„
04:41:28ForumUpdaterBotNew 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:42ForumUpdaterBotNew thread by Geekrelief: Qualify identifier with exported module?, see https://forum.nim-lang.org/t/7852
05:50:44ForumUpdaterBotNew thread by Dabod: Simulate super in Java at compile time, see https://forum.nim-lang.org/t/7853
06:06:24saemBeef 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:44FromDiscord<ElegantBeef> It doesnt do any reasoning there
06:08:01*Gustavo6046 quit (Ping timeout: 265 seconds)
06:09:37FromDiscord<ElegantBeef> Though i suppose it might be able to
06:12:42saemThere is a reason I didn't go down this road, the inference information propagating like that breaks things.
06:13:34FromDiscord<ElegantBeef> Hey i was just toying around after making the macro i doubt this will go into the compiler
06:15:01saemYou're on track to figuring it out though.
06:15:18FromDiscord<ElegantBeef> Wait this isnt a bodge?!
06:16:06saemWell 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:40FromDiscord<ElegantBeef> Lol, the alternative is to pass the type through all the procedures and that felt dirtier
06:17:19saemWell, there is the AST.
06:20:38FromDiscord<ElegantBeef> Considering my understanding of the compiler that doesnt mean much πŸ˜›
06:24:27saemI was going to say shove in nodes as a start via a new field.
06:56:41FromDiscord<ElegantBeef> Well you encouraged me to do it using an extra field on Nodes and it is now on par πŸ˜„
06:56:43saem@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:28FromDiscord<ElegantBeef> I'm 100% certain anyway i approach this will be "wrong"
06:58:02saemGot a diff of the node variety?
06:58:27FromDiscord<ElegantBeef> I just added a `expected: PType`
07:00:50saemI should sleep tonight, if you want to chat about it/work on it tomorrow I'll be about.
07:02:41FromDiscord<ElegantBeef> Ok, well now it works properly afaict
07:04:53FromDiscord<ElegantBeef> https://github.com/nim-lang/Nim/compare/devel...beef331:sillyinfercase Diff if anyone else is interested πŸ˜„
07:12:35saemwith a bit more love that generalises to cover a whole lot more situations. :D
07:14:34FromDiscord<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:54saemYeah, same hesitation. But as the saying goes make it work, make it good, then make it fast.
07:28:57saemI 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:44saemThe 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:42FromDiscord<madman> any idea how to set working directory in nimscript? `setCurrentDir()` is unavailable. thinking of using nake
08:31:37FromDiscord<ElegantBeef> There is a `withDir` template and also a `cd` procedure
08:31:52FromDiscord<ElegantBeef> https://nim-lang.org/docs/nimscript.html lists all the interop'd functions
08:32:28FromDiscord<madman> oh thank you
08:32:33FromDiscord<madman> i was here: https://nim-lang.org/docs/nims.html
08:54:06*natrys joined #nim
09:15:10FromDiscord<mlokis> how come this works?
09:15:29FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=37sl
09:15:34FromDiscord<mlokis> output:
09:15:54FromDiscord<mlokis> sent a code paste, see https://paste.rs/QXq
09:16:58FromDiscord<ElegantBeef> typedesc is a generic, so in that example it only generates a procedure for float, int and string
09:17:29FromDiscord<haxscramper> `float` is `float64`
09:17:36FromDiscord<mlokis> os so each time it generates the is is increased
09:17:44FromDiscord<ElegantBeef> Well yea that's the only time it's ran
09:17:46FromDiscord<mlokis> (edit) "is" => "id"
09:17:59FromDiscord<mlokis> nice
10:01:21*clyybber joined #nim
10:42:41*fredrikhr joined #nim
11:09:34FromDiscord<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:24FromDiscord<haxscramper> https://wandbox.org/permlink/A8QNkqIInsRx05sM to be honest it seems like a bug with current version. devel on wandbox works correctly
11:19:53FromDiscord<haxscramper> Because `TripleKindType` is a typeclass, so your implementation should not fail the way it does not
11:19:55FromDiscord<haxscramper> (edit) "not" => "now"
11:20:32FromDiscord<haxscramper> The only thing that was wrong in your -`test(1, "name", "Bob")` instead of a `test (1, "name", "Bob")`
11:20:48FromDiscord<haxscramper> First one calls `test` with three arguments, second calls with one tuple argument
11:21:01FromDiscord<zidsal> oops, I forgot the brackets when I made my noddy example
11:21:18FromDiscord<haxscramper> But that has nothing to do with your error
11:21:24FromDiscord<zidsal> looks like switching to devel has fixed this in my actual code
11:21:29FromDiscord<zidsal> #bleedingEdge
11:21:33FromDiscord<haxscramper> are you on `1.4.4`?
11:21:37FromDiscord<haxscramper> Or 1.4.6
11:21:37FromDiscord<zidsal> I was on 1.4.6
11:22:45FromDiscord<zidsal> I'll just switch to devel until the next stable release, whenever that is
11:22:52*dv^_^ joined #nim
11:23:26FromDiscord<haxscramper> alternatively you can specify `[T: TripleTypeKind]` in `test`
11:23:33FromDiscord<haxscramper> And make it accent `(int, string, T)`
11:23:53FromDiscord<haxscramper> accept
11:24:25FromDiscord<zidsal> sent a code paste, see https://play.nim-lang.org/#ix=37NS
11:25:43FromDiscord<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:25FromDiscord<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:21ForumUpdaterBotNew Nimble package! unittest2 - unittest fork focused on parallel test execution, see https://github.com/status-im/nim-unittest2
12:19:44FromDiscord<haxscramper> https://nim-lang.org/docs/macrocache.html#CacheCounter
12:20:17FromDiscord<haxscramper> @mlokis macrocache counter
12:46:55FromDiscord<zetashift> In reply to @ForumUpdaterBot "New Nimble package! unittest2": Doesn't testament do parallel test executions too?
13:19:07FromDiscord<mlokis> sent a code paste, see https://paste.rs/CJe
13:19:29FromDiscord<mlokis> it does not compile without pragma
13:27:05FromDiscord<haxscramper> https://play.nim-lang.org/#ix=388d
13:27:17FromDiscord<haxscramper> `const nextTypeID = CacheCounter("counter")` basically
13:30:26FromDiscord<mlokis> is there a macro that i can pass an expression and it will return its type
13:30:46FromDiscord<mlokis> (edit) "is there a macro that i can pass an expression and it will return its type ... " added "ot the expression"
13:31:26ForumUpdaterBotNew Nimble package! hastysite - A small but powerful static site generator powered by HastyScribe and min, see https://hastysite.h3rald.com
13:32:05FromDiscord<mlokis> for example `1` will return `newIdentNode("int")`
13:33:50ForumUpdaterBotNew thread by Masiarek2: Char type: echo ASCII code for 'space' and 'single quote', see https://forum.nim-lang.org/t/7854
13:37:05FromDiscord<haxscramper> In reply to @mlokis "is there a macro": You need to accept `typed` argument
13:37:30FromDiscord<haxscramper> And then `getType` https://nim-lang.org/docs/macros.html#getType%2CNimNode
13:37:46FromDiscord<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:00FromDiscord<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:56FromDiscord<gollark> Never mind, I checked nimble instead of just the stdlib, there is a thing for this.
15:32:38FromDiscord<flywind> there is no warnings anymore
15:32:41FromDiscord<flywind> see devel docs
15:33:20*ozzz joined #nim
15:34:10FromDiscord<flywind> eventually we will have `TempFile`, `TempDir` based on destructors.
15:35:32FromDiscord<flywind> https://nim-lang.github.io/Nim/os.html#getTempDir
15:36:11FromDiscord<flywind> and new modules
15:36:12FromDiscord<flywind> https://nim-lang.github.io/Nim/tempfiles.html
15:36:19FromDiscord<flywind> (edit) "modules" => "module"
16:46:28*Gustavo6046 joined #nim
18:01:21*sagax quit (Quit: Konversation terminated!)
18:05:42FromDiscord<aab> how to cast a pointer to a ref?
18:07:00FromDiscord<Casey.McMahon> sent a code paste, see https://paste.rs/2o9
18:09:49FromDiscord<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:59FromDiscord<whisperdev> I just import chronicles and specify sink in nim.cfg
18:12:49FromDiscord<treeform> When would use use `typed` vs `untyped` when creating a macro? What is the difference?
18:13:40FromDiscord<treeform> oh it explains it here: https://nim-lang.org/docs/tut3.html#introduction-untyped-arguments
18:15:07FromDiscord<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:09FromDiscord<Solitude> sent a code paste, see https://paste.rs/FxC
18:21:40FromDiscord<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:57FromDiscord<Casey.McMahon> sent a code paste, see https://paste.rs/UrJ
18:26:39FromDiscord<Casey.McMahon> sent a code paste, see https://paste.rs/tQ7
18:29:00FromDiscord<aab> sent a code paste, see https://paste.rs/vMH
18:29:37FromDiscord<haxscramper> you cannot cast `ptr` to a `ref`, they are different. `ptr` is manually managed, `ref` is GC-managed data
18:30:07FromDiscord<haxscramper> you can take `addr` for a ref, but not other way around
18:30:13FromDiscord<haxscramper> or `addr refObj[]`
18:30:22FromDiscord<Casey.McMahon> sent a code paste, see https://play.nim-lang.org/#ix=38UA
18:31:41FromDiscord<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:43FromDiscord<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:27FromDiscord<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:05ForumUpdaterBotNew 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:14FromDiscord<Solitude> In reply to @Casey.McMahon "I ended up doing": just convert i to your enum, wth
19:34:20FromDiscord<ElegantBeef> Enums are just fancy ints which means you can convert to/from easily
19:35:11FromDiscord<ElegantBeef> sent a code paste, see https://paste.rs/7Oa
19:49:14FromDiscord<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:39FromDiscord<ElegantBeef> !eval echo cast[string](cast[seq[byte]]("Hello"))
19:52:41NimBotHello
19:53:02FromDiscord<gollark> Isn't cast unsafe?
19:53:12FromDiscord<ElegantBeef> Only unsafe if you dont wear protection
19:53:18FromDiscord<gollark> I see.
19:53:27FromDiscord<ElegantBeef> unsafe doesnt mean dont use it, it means dont use it unless you know what you're doing
19:53:58FromDiscord<ElegantBeef> I believe in this case it's completely fine since we are staying inside Nim
19:54:04FromDiscord<ElegantBeef> But i could be wrong πŸ˜„
19:54:46FromDiscord<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:13FromDiscord<gollark> I was worried because of the fact that they're apparently null-terminated, and my string isn't necessarily.
19:55:26FromDiscord<gollark> isn't necessarily free of nulls, or null-terminated
19:55:30FromDiscord<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:33FromDiscord<gollark> the seq
19:55:37FromDiscord<ElegantBeef> Well Nim strings arent Cstrings
19:55:49FromDiscord<ElegantBeef> you can have a string full of `\0`
19:56:01FromDiscord<demotomohiro> string always have terminating zero but that is not count in .len()
19:56:07FromDiscord<ElegantBeef> Yea
19:56:52FromDiscord<ElegantBeef> seq's and strings have the same type layout where it's a pointer to `cap, length, data`
19:57:18FromDiscord<ElegantBeef> So the casting is fine since that extra information is in the data and only used when converted to a cstring
19:57:48FromDiscord<ElegantBeef> And treeform i've toyed with the compiler and bodged in enum inference πŸ˜„
19:58:02FromDiscord<ElegantBeef> still have to clean it up, but it works πŸ˜›
19:59:57FromDiscord<demotomohiro> Is it possible that binary layout of string or seq will be changed in future and casting them become unsafe?
20:00:12FromDiscord<ElegantBeef> Possibly, stringv2 i think does change the layout
20:00:58FromDiscord<ElegantBeef> Stores the cap and len as the first two values in the data
20:01:08FromDiscord<ElegantBeef> Atleast iirc
20:02:11FromDiscord<ElegantBeef> In that case it's still not difficult to convert
20:04:04FromDiscord<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:18FromDiscord<demotomohiro> Then, casting each char to byte one by one seems safter than casting string to seq[byte] (but slower).
20:05:19FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=39aR
20:06:49FromDiscord<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:20FromDiscord<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:48FromDiscord<gollark> Images are generated at intervals and then may be used to respond to lots of HTTP requests.
20:12:55FromDiscord<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:17FromDiscord<ElegantBeef> Dont know how that fairs with async so... πŸ˜„
20:13:53FromDiscord<gollark> I may just do the somewhat horrible channel thing then.
20:14:22FromDiscord<ElegantBeef> I dont do async or threading much so i'm the worst person to talk here
20:19:48FromDiscord<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:13FromDiscord<demotomohiro> but I never used it.
20:22:21FromDiscord<gollark> IIRC this has issues if the shared thing contains further GCed things.
20:23:00FromDiscord<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:47FromDiscord<ElegantBeef> https://forum.nim-lang.org/t/7475
20:35:54giacobe 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:07FromDiscord<ElegantBeef> You can always just gitignore all non nim/nims files in that directory so it is only local
20:39:21giacosure, but that cleans up the repo, but not the project folder. My vscode workspace looks just messy with all the binaries
20:54:19FromDiscord<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:35FromDiscord<ElegantBeef> You'd need to box the types using an object variant
20:56:06FromDiscord<zidsal> sent a code paste, see https://play.nim-lang.org/#ix=39ja
20:58:43FromDiscord<ElegantBeef> @ajusa something like this https://play.nim-lang.org/#ix=39jz
21:00:12FromDiscord<ElegantBeef> If the page looks dead, refresh until it's not
21:00:27FromDiscord<zidsal> it worries me how quickly you bash our these examples @ElegantBeef
21:00:36FromDiscord<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:12FromDiscord<zidsal> will every type in the table map to the same value?
21:01:21FromDiscord<ElegantBeef> Well if the type cannot be statically known you might have an issue in a static language πŸ˜›
21:01:38FromDiscord<zidsal> same type
21:01:46FromDiscord<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:55FromDiscord<ElegantBeef> Well you can box a lot of values
21:02:07FromDiscord<ElegantBeef> But it's statically typed so you have to be able to statically represent it
21:02:11FromDiscord<zidsal> or make it take generics of a box type?
21:02:22FromDiscord<zidsal> so the box time can be defined later
21:03:21FromDiscord<ElegantBeef> Zidsal i make too many examples for some things i should just bookmark it and add commands to nimbot πŸ˜„
21:03:59FromDiscord<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:06FromDiscord<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:39FromDiscord<ElegantBeef> Well if this is js you can just use the `jsffi` and `JsObject` then dont have to worry about typeps
21:04:44FromDiscord<zidsal> sent a code paste, see https://play.nim-lang.org/#ix=
21:04:44FromDiscord<ElegantBeef> (edit) "typeps" => "types"
21:04:50FromDiscord<ElegantBeef> Well a JsObject
21:04:55FromDiscord<zidsal> or am I mis understanding
21:05:20FromDiscord<ElegantBeef> And a JsObject works like a jsonnode so you can always just use that ;P
21:05:21FromDiscord<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:51FromDiscord<ElegantBeef> Take inspiration for the json node πŸ˜› https://nim-lang.org/docs/json.html#JsonNodeObj
21:06:05FromDiscord<ElegantBeef> Anyway dog's need walked, so best not need any examples!
21:06:13FromDiscord<zidsal> how do macro's work with js frontend? this could potentally work with a cachemap
21:06:16FromDiscord<zidsal> and generics
21:06:16FromDiscord<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:31FromDiscord<ElegantBeef> Macros generate code the exact same
21:06:44FromDiscord<ElegantBeef> We already have jsobject to emulate the js object
21:06:52FromDiscord<ElegantBeef> You can use arbitrary fields to add to it
21:07:12FromDiscord<ElegantBeef> https://nim-lang.org/docs/jsffi.html#%5B%5D%3D%2CJsObject%2Ccstring%2CT
21:08:08FromDiscord<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:45FromDiscord<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:01FromDiscord<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:01FromDiscord<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:55FromDiscord<ElegantBeef> @ajusa you may want to check `withValuee`
21:46:56FromDiscord<ElegantBeef> (edit) "`withValuee`" => "`withValue`"
21:49:20FromDiscord<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:42FromDiscord<ElegantBeef> Oh well yea it copies or sinks the value from the seq
21:49:57FromDiscord<ElegantBeef> you want it to be `ref seq[T]` if you want it to propagate backwards
21:50:02FromDiscord<ajusa> I had a minimal example, clicked publish, and then https://play.nim-lang.org/ failed lol
21:50:21FromDiscord<ajusa> In reply to @ElegantBeef "you want it to": got it, that's pretty much what I ended up going with. I
21:50:46FromDiscord<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:05FromDiscord<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:48ForumUpdaterBotNew 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:15FromDiscord<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:27FromDiscord<ElegantBeef> Which can even be extended to bytes and the like
22:13:32saemcongrats!
22:13:34saemthat's awesome
22:22:06FromDiscord<ElegantBeef> Thought it seems like the non enum values are more complex to remedy
22:22:43giacois there a better way to get the fractional part of a float than "f - f.trunc"?
22:24:38FromDiscord<ElegantBeef> There is split decimal but it probably does something similar
22:25:03reversem3How do you call a url ? var call = httpGet("https://hacker-news.firebaseio.com/v0/topstories.json")
22:25:32FromDiscord<ElegantBeef> https://nim-lang.org/docs/httpclient.html#retrieving-a-website
22:27:09reversem3thanks i thought I had to use httpGet
22:28:24giacothanks
22:36:32reversem3ok 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:25FromDiscord<ElegantBeef> Yea inim probably isnt building with `-d:ssl`
22:43:42FromDiscord<ElegantBeef> You can always use treeform's puppy if you want to do requests without openssl
22:50:49FromDiscord<ajusa> sent a long message, see https://paste.rs/MTl
22:52:01FromDiscord<ElegantBeef> I know what's going here yes totally πŸ˜„
22:52:42reversem3thanks , I'm just teaching my self how to parse out hacker news and hopefully build a gui for it
23:03:20giacoI'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:34FromDiscord<ElegantBeef> Convert to a string is my view
23:04:43giacok
23:04:45FromDiscord<ElegantBeef> So you can remove decimals and then compare those two
23:05:02FromDiscord<ElegantBeef> https://forum.nim-lang.org/t/7850 forum post about it
23:07:39giacothanks as always!
23:09:30*clyybber quit (Remote host closed the connection)
23:14:14ForumUpdaterBotNew Nimble package! nint128 - 128-bit integers, see https://github.com/rockcavera/nim-nint128
23:15:24*xet7 joined #nim
23:34:05giacoI'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:26FromDiscord<ElegantBeef> This part of the manual explains it all https://nim-lang.org/docs/manual.html#types-distinct-type
23:35:30FromDiscord<ElegantBeef> `{.borrow.}`
23:37:57giacoyeah!
23:38:04giacothanks again :D
23:40:06FromDiscord<ElegantBeef> Lol no problem
23:42:36FromDiscord<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)