00:24:39 | FromDiscord | <gogolxdong (liuxiaodong)> How to make a ref from seq[string] ? |
00:25:41 | FromDiscord | <impbox [ftsf]> what are you trying to do? |
00:25:42 | * | stkrdknmibalz joined #nim |
00:27:44 | FromDiscord | <impbox [ftsf]> `var s = new seq[string]()` |
00:29:10 | FromDiscord | <impbox [ftsf]> (edit) "seq[string]()`" => "seq[string]`" |
00:31:45 | FromDiscord | <gogolxdong (liuxiaodong)> that's nice, how about making a ref from a literal seq[string] , like `@["width:100%;height:100%;"]` |
00:33:24 | FromDiscord | <Elegantbeef> follow it with `s[] = @["width:100%;height:100%;"]` or make a template to do it for you |
00:33:57 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ykb |
00:35:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ykd |
00:35:31 | FromDiscord | <Elegantbeef> of course as `makeRef` is a template you also can do `makeRef:` style syntax |
00:37:46 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
00:38:09 | FromDiscord | <Elegantbeef> Clearly should be named `newRef` but i'm a big dumb dumb |
00:45:53 | FromDiscord | <gogolxdong (liuxiaodong)> is there something like `new @["width:100%;height:100%;"]` |
00:47:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3yke |
01:10:45 | * | neurocyte6 joined #nim |
01:13:10 | * | neurocyte quit (Ping timeout: 252 seconds) |
01:13:11 | * | neurocyte6 is now known as neurocyte |
01:59:18 | FromDiscord | <techno3d> whats the difference between procedure and function? |
02:00:18 | FromDiscord | <Elegantbeef> Functions cannot have any side effects, so they cannot access any globalstate or mutate variables that were not passed as mutable |
02:00:39 | FromDiscord | <Elegantbeef> with `strictFuncs` on they cannot even mutate reference parameters without the `var` annotation |
02:00:40 | FromDiscord | <auxym> see https://nim-lang.org/docs/manual.html#pragmas-nosideeffect-pragma |
03:11:26 | FromDiscord | <Alea> In reply to @Yardanico "yeah, it's pretty easy": what profilers would you recommend? |
03:11:32 | FromDiscord | <Hoober> sent a code paste, see https://play.nim-lang.org/#ix=3ykx |
03:12:03 | FromDiscord | <Elegantbeef> depends on the os @Alea i use callgrind/hottie |
03:12:17 | FromDiscord | <Alea> In reply to @Hoober "Very new to nim": the let probably does type inference that return doesn't |
03:14:45 | FromDiscord | <Elegantbeef> you can use `auto` as a return type for when the type annotation doesnt play nicely |
03:15:19 | FromDiscord | <Rika> In reply to @Hoober "Very new to nim": The space and the parentheses make a tuple instead of a function call |
03:15:25 | FromDiscord | <Rika> So you’re passing a tuple to a function |
03:16:15 | FromDiscord | <Elegantbeef> Rika what are you talking about? |
03:17:33 | FromDiscord | <Rika> Did you not see Hoober’s message |
03:17:42 | FromDiscord | <Rika> Ah |
03:17:44 | FromDiscord | <Rika> I misread |
03:17:45 | FromDiscord | <Hoober> In reply to @Elegantbeef "you can use `auto`": That does help, thanks! Still curious if there's a way to get it to work with a tuple return type |
03:17:46 | FromDiscord | <Rika> Really bad |
03:17:58 | FromDiscord | <Rika> I don’t know how I misread that, but whatever |
03:18:09 | FromDiscord | <Elegantbeef> Well i think it's a compiler bug so i'm looking at it right now |
03:18:28 | FromDiscord | <Rika> I feel like it’s to do with implicit genetics |
03:18:37 | FromDiscord | <Elegantbeef> Nah i see the issue right now |
03:20:08 | FromDiscord | <Rika> Did you read the compiler code |
03:20:11 | FromDiscord | <Rika> Because I cannot |
03:20:27 | FromDiscord | <Elegantbeef> Yea i'm trying to fix it right now |
03:20:36 | FromDiscord | <Hoober> Haha, excellent! |
03:20:45 | FromDiscord | <Hoober> Okay, I don't feel so silly for asking now. |
03:21:13 | FromDiscord | <Rika> In reply to @Elegantbeef "Yea i'm trying to": Well what is the issue |
03:21:49 | FromDiscord | <Elegantbeef> It wants to change the type to a builtin typeclass and cannot for obvious reasons |
03:22:21 | FromDiscord | <impbox [ftsf]> is nim likely to ever support serializing a seq of inherited objects? |
03:23:50 | FromDiscord | <Elegantbeef> Shouldnt be unfeasible assuming we can eventually do `getAllThatInherit(X)` |
03:24:16 | FromDiscord | <Elegantbeef> Which honestly i think it kinda needs it to make it less tedious to do stuff |
03:24:36 | FromDiscord | <Elegantbeef> Might be possible with lazy sem being on the way |
03:26:44 | FromDiscord | <Rika> Why ya gotta use a double negative |
03:27:05 | FromDiscord | <Elegantbeef> Cause i think doubly bad |
03:27:32 | FromDiscord | <impbox [ftsf]> I guess until we get a fields iterator that works with rtti it won't be possible |
03:31:24 | FromDiscord | <Hoober> In reply to @Elegantbeef "It wants to change": Let me know if you get a fix up for this! Very curious to follow along.↵↵Should I report it on github, you think? |
03:31:35 | FromDiscord | <Elegantbeef> Yea you should make an issue |
03:31:55 | FromDiscord | <Elegantbeef> I'm only a numpty that can fix basic stuff, if it's more complex than i think it's not going to be fixed by me 😀 |
03:53:12 | FromDiscord | <Rika> Get it fixed or your reputation will drop smh |
03:53:37 | FromDiscord | <Elegantbeef> Aw shit not my reputation, i'm already only slightly above an ant |
04:00:28 | FromDiscord | <Archion> Hi |
04:00:42 | FromDiscord | <Elegantbeef> Hello |
04:01:43 | FromDiscord | <Rika> Hello |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.2.1) |
04:06:30 | * | supakeen joined #nim |
04:07:02 | * | rockcavera quit (Remote host closed the connection) |
04:11:43 | FromDiscord | <Elegantbeef> Well i've "fixed" it , so heres seeing what CI says 😀 |
04:12:15 | FromDiscord | <Rika> Then you didn’t actually fix it and instead caused more bugs |
04:12:30 | FromDiscord | <Elegantbeef> What? |
04:25:59 | FromDiscord | <Elegantbeef> Well you also made me fine another compiler bug so good job! 😛 |
04:28:01 | FromDiscord | <Elegantbeef> Fun semi related bug https://play.nim-lang.org/#ix=3ykH |
04:28:21 | FromDiscord | <JSONBash> is the result of (100.13 - 100.12) a floating point arithmetic (IEEE) artifact in nim? becuase in C it is not the same value. I see other languages match nims result |
04:29:49 | FromDiscord | <Rika> I mean like “and then you accidentally break everything” |
04:29:56 | FromDiscord | <Rika> I’m surprised you didn’t understand what I meant |
04:29:57 | FromDiscord | <Elegantbeef> Ah |
04:30:18 | FromDiscord | <Rika> In reply to @JSONBash "is the result of": Are you subtracting doubles in C? |
04:30:24 | FromDiscord | <Elegantbeef> I'm very very scared of accidently breaking stuff, but my PRs still get accepted so wild 😛 |
04:30:34 | FromDiscord | <Rika> Because float in Nim is double in C |
04:30:35 | FromDiscord | <impbox [ftsf]> nim's float = double in c |
04:30:45 | FromDiscord | <Rika> Hey what the fuck don’t cut me smhhhh |
04:30:54 | FromDiscord | <JSONBash> In reply to @Rika "Are you subtracting doubles": yeah I am |
04:30:57 | FromDiscord | <Elegantbeef> hey imp loses to me often give him this one! |
04:31:07 | FromDiscord | <Rika> But that’s YOU |
04:31:32 | FromDiscord | <Rika> In reply to @JSONBash "yeah I am": Sounds strange then, how are you printing these numbers |
04:31:34 | FromDiscord | <Rika> On C |
04:31:51 | FromDiscord | <impbox [ftsf]> https://play.nim-lang.org/#ix=3ykJ weird! |
04:31:56 | FromDiscord | <JSONBash> `` |
04:32:02 | FromDiscord | <Elegantbeef> It could just be nim's stringication |
04:32:08 | FromDiscord | <JSONBash> sent a code paste, see https://play.nim-lang.org/#ix=3ykK |
04:32:26 | FromDiscord | <Rika> In reply to @Elegantbeef "It could just be": I doubt it |
04:32:41 | FromDiscord | <Rika> I’m thinking it’s something to do with literals and compiler optimisation on C |
04:33:06 | FromDiscord | <impbox [ftsf]> sense... it makes none to me |
04:33:08 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ykL |
04:33:34 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/885382399255523388/image.png |
04:33:35 | FromDiscord | <Elegantbeef> Shame |
04:33:42 | FromDiscord | <JSONBash> I tried that same in clojure, JS, scala and they all printed what nim did |
04:33:50 | FromDiscord | <JSONBash> C was the only one that didn't |
04:34:55 | FromDiscord | <xflywind> I got |
04:34:57 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3ykM |
04:35:08 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3ykN |
04:35:42 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ykO |
04:36:04 | FromDiscord | <Rika> You used f |
04:36:06 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3ykP |
04:36:11 | FromDiscord | <Rika> That prints in float I believe |
04:36:14 | FromDiscord | <impbox [ftsf]> to pay respects |
04:36:20 | FromDiscord | <Rika> I think you use d if you want to print a double |
04:36:25 | FromDiscord | <Rika> I forget |
04:37:45 | FromDiscord | <JSONBash> In reply to @Rika "I think you use": I think %d is for ints |
04:37:58 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3ykQ |
04:38:06 | FromDiscord | <Rika> Hmm |
04:38:10 | FromDiscord | <Rika> F is indeed double |
04:38:13 | FromDiscord | <Rika> But that’s strange |
04:38:36 | FromDiscord | <Rika> Try compiling with all warnings and extra warnings, might show something |
04:39:01 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3ykR |
04:39:21 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3ykS |
04:40:09 | FromDiscord | <xflywind> > g option: Use the shortest representation: %e or %f |
04:40:20 | FromDiscord | <JSONBash> sent a code paste, see https://play.nim-lang.org/#ix=3ykT |
04:40:35 | FromDiscord | <JSONBash> i only have ever used %d and %f to orint really |
04:41:34 | FromDiscord | <Rika> I believe the important part here is the .16 and not the g |
04:41:44 | FromDiscord | <xflywind> yeah |
04:42:20 | FromDiscord | <JSONBash> I also have never printed with .16 lol |
04:42:30 | FromDiscord | <JSONBash> thanks for the answer all |
05:24:45 | FromDiscord | <Elegantbeef> Well rika i'm passing CI now, so put that in your pipe... and i caught the compiler on fire |
05:26:06 | FromDiscord | <Rika> Nice |
05:56:47 | FromDiscord | <cabboose> Hey guys, with the GC_ref and GC_unref call, is that specific to the thread calling it? |
05:57:01 | FromDiscord | <cabboose> so if I pass an object to an intermediary and call GC_ref on the thread sending it |
05:57:15 | FromDiscord | <cabboose> can I then call GC_unref on the thread receiving it and it'll be managed by that thread? |
05:57:18 | FromDiscord | <cabboose> i'm guessing not |
05:57:27 | FromDiscord | <cabboose> doesn't really make sense with how ref objects work |
05:57:35 | FromDiscord | <Elegantbeef> Well depending on your GC it'd be copied over |
05:57:43 | FromDiscord | <cabboose> using refc |
05:57:54 | FromDiscord | <Elegantbeef> Then no, refc doesnt have shared heaps |
05:58:15 | FromDiscord | <cabboose> hmm |
06:02:40 | FromDiscord | <cabboose> does owned function by registering the ref with the GC? |
06:02:50 | FromDiscord | <cabboose> so could move semantics be used to transfer the ref to another GC? |
06:03:05 | FromDiscord | <cabboose> and using allocshared in the intermediary |
06:03:19 | FromDiscord | <cabboose> que nah that seems stupid |
06:03:58 | FromDiscord | <Elegantbeef> There is `std/isolation` but idk how supported it is 😀 |
06:07:13 | FromDiscord | <cabboose> Looks good |
06:07:57 | FromDiscord | <cabboose> The ownership of the refs isn't hard to reason with on my side |
06:08:01 | FromDiscord | <cabboose> so hopefully can get that working |
07:06:43 | * | PMunch joined #nim |
07:49:36 | * | max22- joined #nim |
07:52:22 | * | NeoCron joined #nim |
07:56:02 | FromDiscord | <cabboose> So strings that get converted to cstring are truncated to 128 len? |
07:57:29 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ylx |
07:57:33 | FromDiscord | <Elegantbeef> They really cant since the cstring is the string |
07:57:52 | FromDiscord | <cabboose> I'm having a json truncated when converted to cstring |
07:57:57 | FromDiscord | <Elegantbeef> Nim puts a `\0` at the end of the string as a hidden element |
07:58:06 | FromDiscord | <Rika> Show code |
07:58:12 | FromDiscord | <Elegantbeef> You sure it just doesnt have a `\0` somewhere? |
07:58:24 | FromDiscord | <cabboose> hmm maybe; i'm using jsony |
07:58:26 | FromDiscord | <cabboose> {"dob":"2021-09-09 03:57:20","entit":{"kind":"Non","mcare":"","conc":"","snet":"","rpat":"","ndss":"","ctg_stat":false},"gndr":"","sx":"","deceased":false,"facility":0,"name":{0:""},"contact":{"p":"","h":"","m":"","f":"","e":""},"status":false,"address":{0:" ",1:" ",2:" "},"did":0,"wid":0,"uids":[],"pid":5} |
07:58:31 | FromDiscord | <cabboose> that's the json i'm trying to convert |
07:58:41 | FromDiscord | <cabboose> sent a code paste, see https://play.nim-lang.org/#ix= |
07:58:44 | FromDiscord | <cabboose> gets truncated to that |
07:58:55 | FromDiscord | <cabboose> (edit) "{"dob":"2021-09-09 03:57:20","entit":{"kind":"Non","mcare":"","conc":"","snet":"","rpat":"","ndss":"","ctg_stat":false},"gndr":"","sx":"","deceased":false,"facility":0,"name":{0:""},"contact":{"p":"","h":"","m":"","f":"","e":""},"status":false,"address":{0:" ",1:" ",2:" "},"did":0,"wid":0,"uids":[],"pid":5}" => "sent a code paste, see https://play.nim-lang.org/#ix=" |
07:59:13 | FromDiscord | <Elegantbeef> `assert '\0' notin yourStringdJson` |
07:59:24 | FromDiscord | <cabboose> oki gimme a sec |
07:59:26 | FromDiscord | <Rika> Don’t run in danger |
07:59:30 | FromDiscord | <Rika> Use release |
08:01:10 | FromDiscord | <cabboose> Oh right I'm stupid |
08:01:19 | FromDiscord | <cabboose> I made default gndr and sx '\0' |
08:01:21 | FromDiscord | <cabboose> jesus |
08:01:23 | FromDiscord | <cabboose> kill me |
08:01:26 | FromDiscord | <Elegantbeef> I dont imagine a `\0` got encoded into the json |
08:01:31 | FromDiscord | <Elegantbeef> Lol |
08:01:35 | FromDiscord | <Elegantbeef> Cstrings are lovely eh |
08:01:36 | FromDiscord | <cabboose> not unless you specifically put it in |
08:01:40 | FromDiscord | <cabboose> 😂 |
08:01:42 | FromDiscord | <cabboose> thanks ❤️ |
08:24:35 | * | darwillim86d joined #nim |
08:27:37 | * | jjido joined #nim |
08:34:05 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
08:51:39 | * | jjido joined #nim |
08:58:27 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
09:06:29 | * | TakinOver quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
09:27:58 | * | PMunch quit (Ping timeout: 260 seconds) |
10:13:37 | FromDiscord | <Archion> Sport is bad |
10:14:17 | * | PMunch joined #nim |
10:18:52 | FromDiscord | <Rika> ? |
10:32:02 | * | jjido joined #nim |
10:48:40 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
10:49:44 | * | Vladar joined #nim |
11:17:25 | * | max22- quit (Ping timeout: 260 seconds) |
11:31:08 | FromDiscord | <bolino> Hi! I'd like to have a structure of Tables in Table, equivalent to a dict of dicts in python (mydict = `{"key1":{"key11":"value11", "key12":"value12"},"key2":{"key21":"value21", "key22":"value22"}}`) |
11:31:37 | FromDiscord | <bolino> (edit) ""key22":"value22"}}`)" => ""key22":"value22"}}`)↵↵I wonder why I can't initialize it with `var sp = Table[string, Table[string, string]]`?" |
11:32:02 | PMunch | Try `var sp: Table[string, Table[string, string]] |
11:32:11 | PMunch | `var sp: Table[string, Table[string, string]]` |
11:32:24 | PMunch | Note the colon instead of the equal sign |
11:32:39 | FromDiscord | <greenpete> Are there any Nim lang podcasts? |
11:33:03 | FromDiscord | <bolino> Ah yeah of course! Thanks. Or I can use `newTable` I guess also |
11:33:09 | PMunch | @greenpete, none that I know of. Closest you'll get at the moment is the monthly live chat |
11:33:12 | FromDiscord | <bolino> thank you!! |
11:33:19 | PMunch | No problem :) |
11:35:16 | FromDiscord | <Rika> In reply to @bolino "Ah yeah of course!": Not new, init |
11:35:17 | FromDiscord | <enthus1ast> and there also is the "This Month in Nim" |
11:35:30 | FromDiscord | <enthus1ast> https://nim-lang.org/blog.html |
11:35:45 | FromDiscord | <Yardanico> that's what PMunch talked about :) |
11:36:40 | FromDiscord | <enthus1ast> is this also a live talk? |
11:37:23 | FromDiscord | <Yardanico> oh sorry he mentioned the meeting then I guess |
11:37:44 | PMunch | Yeah I was talking about the meeting :P |
11:38:43 | FromDiscord | <greenpete> Thanks!↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
11:42:23 | FromDiscord | <ant1fact> Hello everyone, I am just picking up nim after python for a small project and I am trying to do things as correctly as possible. I need some simple but important data types which are mostly different sized vectors of floats and ints. When creating these types, should I use object or a tuple instead? I cannot find a straightforward answer about this. Are there pros and cons to them? |
11:42:29 | FromDiscord | <ant1fact> (edit) "Hello everyone, I am just picking up nim after python for a small project and I am trying to do things as correctly as possible. I need some simple but important data types which are mostly different sized vectors of floats and ints. When creating these types, should I use object or a tuple instead? I cannot find a straightforward answer about this. Are there pros and cons to them? ... " added "Thanks" |
11:43:02 | FromDiscord | <haxscramper> Use object |
11:43:08 | FromDiscord | <haxscramper> `tuple` is a throwaway anonymous single-use thing |
11:43:19 | FromDiscord | <enthus1ast> tuples have all their fields visible, object fields must be exported |
11:43:48 | FromDiscord | <enthus1ast> (from other modules) |
11:48:05 | FromDiscord | <ant1fact> I am not convinced that you are actual bots : ) |
11:50:39 | FromDiscord | <haxscramper> this is a discord \<-\> matrix bridge |
11:50:47 | PMunch | I'd say use objects, they both look the same in memory on runtime, but have slightly different semantics on compile-time. |
11:53:56 | * | jjido joined #nim |
11:58:14 | FromDiscord | <ant1fact> Thanks for all the info |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2.1) |
12:06:32 | * | supakeen joined #nim |
12:09:36 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
12:25:41 | FromDiscord | <ant1fact> Are there any best practices for parsing large text files (millions of lines) to increase performance? |
12:27:00 | FromDiscord | <enthus1ast> do it line by line (if you can), do not use split("\\n") but eg. lines iterator, maybe strscan or parseutils are your friends |
12:27:38 | FromDiscord | <enthus1ast> or even do everything yourself |
12:27:56 | FromDiscord | <ant1fact> is readFile(f).splitLines() ok or better to go with readLine() ? |
12:27:57 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
12:29:13 | FromDiscord | <Rika> splitlines will process the whole file most likely |
12:29:19 | FromDiscord | <Rika> use iterators |
12:29:31 | FromDiscord | <enthus1ast> there is `lines` https://nim-lang.org/docs/io.html#lines.i%2Cstring |
12:29:47 | FromDiscord | <ant1fact> mostly what I need to do is parse ints and floats out of lines. for floats I can use scanf() because I always expect 3 of them so I can do $f $f $f but for ints the number of ints in the line can change, any best alternative to scanf() in that case? |
12:30:19 | FromDiscord | <Rika> there is parseutils as enthusiast says |
12:30:33 | FromDiscord | <ant1fact> I wrote a proc that uses parseFloat but I also use .split(' ') on the line |
12:30:42 | FromDiscord | <Rika> its ok to split on lines |
12:30:45 | FromDiscord | <Rika> just do not split to get lines |
12:30:50 | FromDiscord | <ant1fact> ahhh |
12:30:51 | FromDiscord | <ant1fact> ok! |
12:30:55 | FromDiscord | <Rika> unless your lines are also long, then split might be slow |
12:31:07 | FromDiscord | <enthus1ast> but for great performance, i would not backtrack |
12:31:27 | FromDiscord | <ant1fact> where does the backtracking happen at the moment? |
12:31:29 | FromDiscord | <enthus1ast> there is no need to split the line first |
12:31:56 | FromDiscord | <enthus1ast> but parseFloat ; skipWhitespace ; parseFloat ; etcc... |
12:32:11 | FromDiscord | <ant1fact> hmmm |
12:32:17 | FromDiscord | <ant1fact> may not even need lines then |
12:32:22 | FromDiscord | <enthus1ast> when you encounter newline yield |
12:32:25 | FromDiscord | <ant1fact> just store floats every 3 floats |
12:32:33 | FromDiscord | <Rika> is it strictly 3 floats? |
12:32:36 | FromDiscord | <ant1fact> for floats yes |
12:32:37 | FromDiscord | <Rika> if it is then you dont need lines |
12:32:39 | FromDiscord | <ant1fact> for ints its variable |
12:32:43 | FromDiscord | <Rika> oh hm |
12:32:44 | FromDiscord | <ant1fact> thats where i am struggling |
12:32:49 | FromDiscord | <ant1fact> ints can be 3 |
12:32:51 | FromDiscord | <ant1fact> 4 |
12:32:52 | FromDiscord | <ant1fact> 5 |
12:33:13 | FromDiscord | <Rika> then lines is still ok |
12:35:18 | * | rockcavera joined #nim |
12:35:19 | * | rockcavera quit (Changing host) |
12:35:19 | * | rockcavera joined #nim |
12:36:28 | FromDiscord | <ant1fact> Really appreciate all the tips, folks |
12:36:33 | FromDiscord | <ant1fact> Having a blast with nim |
12:42:20 | FromDiscord | <bolino> Same here, really appreciate the community, you guys are super helpful! The community is really the most important criteria for a language 🙂 |
12:46:01 | * | max22- joined #nim |
12:46:55 | PMunch | We try our best (for the most part) |
12:55:26 | * | arkurious joined #nim |
12:57:12 | PMunch | Damn, finding a good dithering algorithm that can run on a GPU is hard |
12:58:44 | PMunch | Any ordered/positional algorithm will work, but those typically look pretty bad |
12:58:55 | FromDiscord | <Rika> have you seen about "a dither"? |
12:59:04 | * | max22- quit (Quit: Leaving) |
12:59:06 | PMunch | Huh? |
12:59:16 | FromDiscord | <Rika> the name oft he algo |
12:59:18 | FromDiscord | <Rika> is "a dither" |
12:59:23 | FromDiscord | <Rika> https://pippin.gimp.org/a_dither/ |
12:59:27 | FromDiscord | <Rika> certainly confusing |
12:59:32 | FromDiscord | <Rika> but i think it looks pretty good |
12:59:48 | FromDiscord | <Rika> unless you've implemented void-and-cluster |
13:00:00 | FromDiscord | <Rika> which is kinda hard, its pretty complex |
13:01:37 | PMunch | Void and cluster is also positionally complex.. |
13:01:43 | PMunch | computationally* |
13:02:22 | FromDiscord | <Rika> a dither is pretty fast i think |
13:02:25 | FromDiscord | <Rika> still needs floats |
13:02:35 | FromDiscord | <Rika> but you can use 32s and it should be fine |
13:02:37 | FromDiscord | <Rika> maybe even 16s |
13:02:49 | FromDiscord | <Rika> prolly implementable as a shader |
13:03:29 | PMunch | Ooh, a dither seems promising |
13:03:59 | FromDiscord | <Rika> it doesnt help that its name is so generic lmao |
13:04:18 | FromDiscord | <Rika> whats the dithering for btw |
13:05:23 | PMunch | An eInk screen |
13:05:38 | FromDiscord | <Rika> saaaaaame |
13:05:49 | FromDiscord | <Rika> i was planning on using it for my eink screen too |
13:05:55 | FromDiscord | <Rika> but i cant implement it on gpu... |
13:06:24 | FromDiscord | <Rika> since it's not an opengl context (it's a regular android one) and i dont know how to program on gpu for that... |
13:06:30 | PMunch | It's a computer monitor with HDMI input, but the dithering that comes with it appears to be something like Floyd-Steinberg. So when I move the mouse all the pixels to the right and down from the cursor updates which looks terrible when you consider ghosting.. |
13:07:09 | FromDiscord | <Rika> how will you disable the internal dithering? |
13:07:51 | PMunch | Either by just setting it to BW mode, or by using another driver board |
13:09:59 | PMunch | You wouldn't happen to have a dither implemented in Nim would you? |
13:12:25 | FromDiscord | <Rika> i do |
13:12:29 | FromDiscord | <Rika> but its cpu ofc |
13:12:36 | PMunch | Of course |
13:12:41 | PMunch | I just wanted to try it out |
13:13:10 | FromDiscord | <Rika> ill just pastebin it okay |
13:14:06 | PMunch | Sure |
13:14:29 | FromDiscord | <Rika> give me a moment then |
13:19:33 | * | max22- joined #nim |
13:24:07 | FromDiscord | <Rika> https://cryptpad.fr/code/#/2/code/view/dZ57STcjOOkYfzoGEPt2VLiRur3ezDJrC-mfJLlNk04/embed/ |
13:24:08 | FromDiscord | <Rika> i think that works |
13:25:06 | FromDiscord | <Archion> Mhm |
13:25:10 | PMunch | Ah, you have processed it quite a bit :P |
13:25:21 | FromDiscord | <Archion> Why are you do this bot thing when there are tupperbox bot |
13:25:23 | FromDiscord | <Archion> A |
13:25:30 | FromDiscord | <Rika> er is that bad or good |
13:25:37 | FromDiscord | <Rika> i made it when i was still learning nim mind you |
13:25:39 | FromDiscord | <Rika> 😛 |
13:26:42 | FromDiscord | <Rika> for per-channel/rgb versions you have to run the same thing per channel |
13:26:52 | FromDiscord | <Rika> so greyscale is 3x faster |
13:31:35 | PMunch | Good thing I'll be doing grayscale then :) |
13:32:14 | FromDiscord | <Rika> i mean, is the input pre-processed into greyscale? |
13:32:36 | FromDiscord | <Rika> i guess you can just add that to the shader actlly |
13:35:12 | PMunch | I would definitely have to do that for the real shader |
13:35:24 | PMunch | Now I'm just testing dithering algorithms on pngs :P |
13:36:36 | FromDiscord | <Rika> i was about to send image examples but i forgot i used an nsfw image |
13:40:22 | FromDiscord | <Yardanico> lol |
13:46:53 | PMunch | Hmm, this is pretty interesting |
13:47:01 | PMunch | But I can't really tell how it actually works :P |
13:48:00 | FromDiscord | <Rika> well it IS just magic numbers |
13:48:37 | PMunch | Sure, but how did he come up with them :P |
13:48:43 | PMunch | And are there better ones out there? |
13:49:00 | FromDiscord | <Rika> probably experimentation |
13:49:06 | FromDiscord | <Rika> better ones? no clue |
13:49:11 | FromDiscord | <Rika> it would probably be on the site |
13:49:12 | FromDiscord | <Rika> if there were |
13:49:19 | FromDiscord | <Rika> it says on the bottom of the site |
13:49:27 | PMunch | I'm kinda tempted to write a error function and just brute force the numbers |
13:49:28 | FromDiscord | <Rika> `If someone comes up with better magic numbers to use on variations of the above formulas, please tell me` |
13:49:36 | FromDiscord | <Rika> call me if you do |
13:49:41 | PMunch | Really only two numbers for the addition algorithm |
13:49:50 | FromDiscord | <Rika> well if you do AND decide it should be either pubdomain or open source |
13:50:04 | FromDiscord | <Rika> for the add one its three |
13:50:11 | FromDiscord | <Rika> ah, no |
13:50:13 | FromDiscord | <Rika> two yeah |
13:50:18 | FromDiscord | <Rika> 237 and 119 |
13:50:58 | PMunch | I guess they should be in the range 0..255 |
13:51:09 | FromDiscord | <Rika> yes |
13:51:16 | PMunch | Meaning there's about 64k possibilities |
13:51:41 | FromDiscord | <Rika> for those wondering why it's `and 255`, it acts like a "faster" mod operation |
13:52:57 | FromDiscord | <impbox [ftsf]> I made a dither thing recently |
13:53:02 | FromDiscord | <impbox [ftsf]> Interesting stuff |
13:53:55 | FromDiscord | <Rika> an a dither thing or a dither thing |
13:54:10 | FromDiscord | <impbox [ftsf]> Yadither |
13:54:14 | FromDiscord | <Rika> ? |
13:54:21 | FromDiscord | <impbox [ftsf]> Yet another |
13:54:50 | FromDiscord | <impbox [ftsf]> But basically building a lookup table of ascending numbers |
13:55:12 | FromDiscord | <Rika> ah yeah you can do that for a dither as well, i just havent figured that out 🙂 |
13:55:15 | FromDiscord | <impbox [ftsf]> Then using that with a per pixel threshold |
13:55:47 | FromDiscord | <Rika> well i figured it out mentally i mean, i just havent coded it |
13:55:55 | FromDiscord | <impbox [ftsf]> Similar to a bayer dither but with a different layout |
13:56:14 | FromDiscord | <impbox [ftsf]> I guess you can experiment with different layouts to see what gives the aesthetic you want |
13:57:08 | FromDiscord | <impbox [ftsf]> If you take a X by Y array and fill it with numbers from 1..XY |
13:57:37 | FromDiscord | <impbox [ftsf]> In a way that adjacent numbers are far apart spatially |
13:57:55 | FromDiscord | <impbox [ftsf]> Taking into account the grid wraps on both axes |
13:58:42 | FromDiscord | <impbox [ftsf]> You can compute an optimal one, but maybe a less optimal solution will look more aesthetically pleasing |
13:59:10 | FromDiscord | <bolino> sent a long message, see http://ix.io/3yn9 |
13:59:28 | FromDiscord | <bolino> (edit) "http://ix.io/3yn9" => "http://ix.io/3yna" |
13:59:43 | FromDiscord | <impbox [ftsf]> `for v in variants.mitems:` |
13:59:55 | FromDiscord | <impbox [ftsf]> Will give you a mutable iteration |
14:00:02 | PMunch | I looked at some bayer dithers, but the results are so bad :( |
14:00:28 | FromDiscord | <impbox [ftsf]> They're not the prettiest |
14:00:46 | FromDiscord | <impbox [ftsf]> Did you check the article on Obra Dinns Dithering? |
14:01:24 | PMunch | Oh damn, I didn't even think of that! |
14:01:35 | PMunch | I read it when the game came out, just as a curiosity |
14:01:53 | FromDiscord | <bolino> sent a code paste, see https://play.nim-lang.org/#ix=3ynd |
14:01:57 | PMunch | But I remember them talking about looking for something that would be stable with animations |
14:02:18 | FromDiscord | <Rika> make your table mutable |
14:02:20 | FromDiscord | <Rika> let -> var |
14:02:43 | FromDiscord | <impbox [ftsf]> Blue noise dithering |
14:03:16 | FromDiscord | <Rika> blue noise dithering is similar to void and cluster |
14:03:38 | FromDiscord | <Rika> personally i prefer the look of "a dither add" |
14:04:07 | FromDiscord | <bolino> sent a code paste, see https://play.nim-lang.org/#ix=3yne |
14:04:20 | FromDiscord | <Rika> looks correct |
14:04:35 | FromDiscord | <bolino> can it become immutable when passed to a function? |
14:04:39 | FromDiscord | <Rika> do you call the for loop in a function |
14:04:40 | FromDiscord | <Rika> yes |
14:04:42 | FromDiscord | <Rika> it can |
14:04:46 | FromDiscord | <bolino> it's initailized elsewhere |
14:04:50 | FromDiscord | <Rika> `variants: var seq[...]` |
14:05:01 | FromDiscord | <Rika> instead of what you have on the parameters right now |
14:05:09 | FromDiscord | <bolino> Thanks, ok, let me try |
14:05:25 | FromDiscord | <bolino> (I'm always confused about the initialization in Nim) |
14:07:35 | FromDiscord | <bolino> (you mean `var variants: seq[...]` right?) |
14:07:41 | PMunch | Hmm, Obra Dinn dithering is unfortunately very much based on having control over the rendering.. |
14:08:13 | FromDiscord | <Rika> In reply to @bolino "(you mean `var variants:": no |
14:08:14 | FromDiscord | <Rika> i do not |
14:08:16 | PMunch | I mean I have control over the windows, so I can dither on a window by window basis and exclude the mouse. That by itself will help immensely |
14:08:21 | FromDiscord | <Rika> i mean put that in the fucntion parameters |
14:08:35 | FromDiscord | <Rika> `proc aaaa(variants: var seq[...], ...` |
14:08:48 | FromDiscord | <enthus1ast> var in functions is like "in out" in other langs |
14:09:27 | FromDiscord | <bolino> In reply to @Rika "i mean put that": Oooh ok |
14:09:56 | FromDiscord | <enthus1ast> by default function parameters are not mutable |
14:10:28 | PMunch | Hmm, what would be a good error function? Total error in the image? |
14:12:21 | FromDiscord | <bolino> @Rika Works! Thanks! Learned something. |
14:12:32 | FromDiscord | <Rika> congrats |
14:12:47 | FromDiscord | <Rika> meanwhile im suffering trying to learn android programming xddd |
14:12:50 | FromDiscord | <bolino> Now I have to figure out out to delete a key/value pair from a table from the key - looks like .del() doesn't do the trick |
14:13:01 | FromDiscord | <bolino> In reply to @Rika "meanwhile im suffering trying": Kotlin? |
14:13:19 | FromDiscord | <Rika> kotlin, opengl, trying to do the same thing as pmunch but on a fucking android app |
14:13:34 | FromDiscord | <Rika> In reply to @bolino "Now I have to": del should do the trick |
14:13:41 | FromDiscord | <Rika> as long as you do not have duplicate values for the same key |
14:13:44 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/tables.html#del%2CTable%5BA%2CB%5D%2CA↵(@bolino) |
14:13:47 | PMunch | You know Android has OpenGL right? |
14:13:55 | FromDiscord | <bolino> By the way I remember a few articles from Lucas Pope on forums when he was coding Obra Dinn |
14:13:55 | FromDiscord | <enthus1ast> but be aware that you should not delete stuff while iterating over it |
14:13:59 | FromDiscord | <Rika> i just said that pmunch |
14:14:01 | PMunch | You can use Nim on Android :P |
14:14:02 | FromDiscord | <Rika> look at the start of my msg |
14:14:09 | PMunch | Yeah I just realised :P |
14:14:11 | FromDiscord | <Rika> cpu dithering is still slow |
14:14:53 | FromDiscord | <Rika> im not sure how a slow draw function would affect this tablet but i cant imagine it being ok |
14:15:12 | FromDiscord | <bolino> In reply to @enthus1ast "https://nim-lang.org/docs/tables.html#del%2CTable%5": yup but doesn't work in my case, need to figure out why |
14:15:35 | FromDiscord | <enthus1ast> what means 'doesn't work' ? |
14:15:57 | FromDiscord | <bolino> oh sorry my bad. it's fine |
14:16:00 | FromDiscord | <bolino> thanks guys! |
14:16:01 | FromDiscord | <Rika> he doesnt know |
14:16:01 | FromDiscord | <Rika> ah |
14:16:09 | FromDiscord | <Rika> slow msg sending sorry xd |
14:16:15 | FromDiscord | <bolino> that's ok |
14:16:46 | FromDiscord | <Rika> man im almost tempted trying to make a custom rom for this tablet but then i dont know how i would install it... |
14:16:47 | FromDiscord | <Rika> hmm |
14:16:52 | FromDiscord | <Rika> my options are limited xd |
14:17:49 | FromDiscord | <enthus1ast> closed hardware will be a big problem in the future... |
14:18:23 | FromDiscord | <Rika> in the future??? its already one now |
14:18:49 | FromDiscord | <enthus1ast> at least most notebooks still allow you to install your desired os |
14:19:48 | NimEventer | New thread by DPixie: Passing JsonNode from Nimscript to host proc, see https://forum.nim-lang.org/t/8407 |
14:22:01 | * | PMunch quit (Quit: Leaving) |
14:22:08 | FromDiscord | <enthus1ast> yeah, there should be some best practices documented somewhere how to shouvle data back and forth the vm |
14:22:18 | FromDiscord | <enthus1ast> useing json seems like a dirty hack to me |
14:24:12 | FromDiscord | <haxscramper> `const runtimeData = newLit(<compile-time data>)` |
14:24:32 | FromDiscord | <haxscramper> or `let runtimeData = newLit(<CT data>)` |
14:25:20 | FromDiscord | <enthus1ast> is it really so simple? |
14:25:36 | FromDiscord | <enthus1ast> will play with it later |
14:27:04 | FromDiscord | <haxscramper> `newLit()` generates object constructor for your data, so it is the same as writing `MyType(field1: ..., field2: ...)` and so on |
14:27:23 | FromDiscord | <haxscramper> it has some limitations IIRC, but for data that makes sense to be transferred from VM it is good enough |
14:27:51 | FromDiscord | <haxscramper> Like if you have complex cyclic `ref` graph it would probably be weird |
14:43:51 | FromDiscord | <haxscramper> [leorize](https://matrix.to/#/@leorize:envs.net)\: Is it possible to pin to `1.4.8` specifically in https://github.com/alaviss/setup-nim |
14:43:54 | nrds | <R2D299> itHub: 7"CI helpers to setup Nim using prebuilt nightlies" |
14:44:35 | FromDiscord | <haxscramper> Now 1.4.9 is available, and it breaks some things in my code, so I need to pin it to specific pathc |
14:45:13 | FromDiscord | <haxscramper> Just doing ` nim: ['version-1-4-8']` results in `Error: Could not find any release named 'latest-version-1-4-8'. The provided branch (version-1-4-8) might not be tracked by nightlies, or is being updated.` |
14:48:46 | FromDiscord | <ynfle (ynfle)> What does "in scope" mean regarding `declaredInScope`? |
14:51:57 | FromDiscord | <haxscramper> I would assume it means "identifier can be accessed from current scope" |
14:52:37 | FromDiscord | <ynfle (ynfle)> and `declared`? |
14:52:43 | FromDiscord | <haxscramper> identifier exists |
14:52:43 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3ynr |
14:53:25 | FromDiscord | <haxscramper> ... this gets tricky when you consider templates/generics etc |
14:54:02 | FromDiscord | <bolino> What would be the best way to remove/delete several items from a sequence?↵If I loop over it to get the indexes to delete, then delete one, it changes the indexes. |
14:54:07 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3yns |
14:54:51 | FromDiscord | <Archion> This is |
14:54:59 | FromDiscord | <Archion> Too complicated for me |
14:56:20 | FromDiscord | <enthus1ast> i would return a new sequence |
14:56:45 | FromDiscord | <bolino> In reply to @enthus1ast "i would return a": Yeah I guess no choice... |
14:59:30 | FromDiscord | <enthus1ast> with the items filtered you dont want |
14:59:32 | FromDiscord | <haxscramper> If you only need to filter out the sequence you can do `import std/sequtils; mySeq.filterIt(predicate it)` |
14:59:33 | FromDiscord | <ynfle (ynfle)> is the playground down? |
14:59:39 | FromDiscord | <haxscramper> seems like it |
15:00:30 | FromDiscord | <haxscramper> https://tio.run/##y8vM/f@/oCg/WSE/OzokViOxKN1KIURTwVYhNTkjXyElNTknsSg1RQPK8EksSS3SVODKz9YwNNLkykktUUCWAWozNDIGIpACpZLy1JIiJU2o4v//AQ |
15:00:44 | FromDiscord | <haxscramper> god, this link is like |
15:01:29 | FromDiscord | <haxscramper> Absolutely insane, especially compared to ix.io or wandbox |
15:01:31 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3ynD |
15:01:35 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/eZq |
15:02:14 | FromDiscord | <haxscramper> This code outputs true/false invocations after because `declared` seems to check that entry is declared in the scope of the first instantiation |
15:02:33 | FromDiscord | <haxscramper> second `ok(12)` does not instantiate anything new, so it uses old definition |
15:03:05 | FromDiscord | <haxscramper> and old defn. was first instantiated in place where `declaredLater` was `not declared` |
15:03:43 | FromDiscord | <haxscramper> declaredInScope just does false on all, but I'm not sure why |
15:07:46 | FromDiscord | <enthus1ast> mh [haxscramper](https://matrix.to/#/@haxscramper:matrix.org) when i try fromLit real quick i get " `false` not yet supported\: Foo [AssertionDefect]" |
15:08:10 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3ynI |
15:08:16 | FromDiscord | <haxscramper> from Lit? |
15:08:17 | FromDiscord | <enthus1ast> (even withouth the seq) |
15:08:20 | FromDiscord | <enthus1ast> yep |
15:08:26 | FromDiscord | <enthus1ast> i want to get data from the vm |
15:08:29 | FromDiscord | <haxscramper> I've never used from lit |
15:08:48 | FromDiscord | <haxscramper> If you need to get data from vm you need to `newLit()` |
15:08:59 | FromDiscord | <haxscramper> Take VM data and generate literal value |
15:09:11 | FromDiscord | <haxscramper> And then assign literal value to some runtime whatever |
15:09:55 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/compiler/vmconv.html#fromLit%2CPNode%2Ctypedesc |
15:10:59 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3ynJ |
15:11:03 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3ynK |
15:11:05 | FromDiscord | <haxscramper> asdf |
15:11:16 | FromDiscord | <haxscramper> you were talking vm, like nim VM |
15:11:44 | FromDiscord | <haxscramper> Not in context of macros |
15:12:15 | FromDiscord | <enthus1ast> yes |
15:12:35 | FromDiscord | <haxscramper> Well, moving data across VM boundaries is an open question for now, but when 1.6 comes out with `cast(uncheckedAssign)` I think I would be able to make pretty simple deserialization tool |
15:12:45 | FromDiscord | <haxscramper> But VM data is just `PNode` |
15:13:56 | FromDiscord | <haxscramper> https://discord.com/channels/371759389889003530/371759389889003532/866296935077904404 |
15:15:30 | FromDiscord | <haxscramper> So it all comes down to `PNode` deserialization, and there is no solution that works reliably for it |
15:15:58 | FromDiscord | <haxscramper> But again, with 1.6 I think I will implement this for hnimast, since I also need to for some things |
15:16:47 | FromDiscord | <haxscramper> PMunch also proposed using json IIRc |
15:17:20 | FromDiscord | <enthus1ast> yes |
15:17:36 | FromDiscord | <enthus1ast> i do this now and it works |
15:17:56 | FromDiscord | <enthus1ast> but it seems a little strange to me to leave nim land while deep in nim land |
15:18:49 | FromDiscord | <haxscramper> Yes. But as I said, my hypotheis is that direct (de)serialization via PNode is the fastests by definition method |
15:19:09 | FromDiscord | <haxscramper> But I need to implement it |
15:19:46 | FromDiscord | <haxscramper> "just" |
15:21:43 | FromDiscord | <enthus1ast> it seems that fromLit was made for this purpose? |
15:22:02 | FromDiscord | <haxscramper> well, does it work? |
15:22:04 | FromDiscord | <enthus1ast> but yeah |
15:22:08 | FromDiscord | <enthus1ast> no \:D |
15:22:41 | FromDiscord | <haxscramper> In cases like this I prefer to just roll my solution, since putting this in compiler/fixing fromLit would divert compiler dev's attention |
15:23:09 | FromDiscord | <haxscramper> and I get faster feedback loop, and can tweak what I need immediately |
15:23:11 | FromDiscord | <enthus1ast> i must admit that i was quite surpirsed that there is no good way to do this |
15:23:26 | FromDiscord | <haxscramper> well, nim vm officially "does not exist" |
15:23:33 | FromDiscord | <haxscramper> like, it is an internal compiler API |
15:23:45 | FromDiscord | <enthus1ast> naaah it is advertised as a scripting language \:) |
15:23:59 | FromDiscord | <haxscramper> And you are one of five? people that actually dived deep enough to hit the bottom |
15:24:10 | FromDiscord | <haxscramper> I"m not saying it takes a lot to do this, but |
15:24:32 | FromDiscord | <haxscramper> well, when yardanico made package graph there were two package group total, that required compier |
15:24:33 | FromDiscord | <haxscramper> My hnimast and godot |
15:25:13 | FromDiscord | <haxscramper> so it is not popular enough yet for official guide to appear. I just sit here/in telegram and answer question like this, |
15:25:48 | FromDiscord | <haxscramper> But I"m considering writing an article about this, at least when I will have somewhat clear(er) picture of what I should put in there |
15:25:57 | FromDiscord | <haxscramper> not vm, but in general |
15:26:07 | FromDiscord | <haxscramper> "getting started with nim comiler API" |
15:26:47 | FromDiscord | <enthus1ast> to me it seems like this question especially "how to use nimvm for my dynamic scripting" comes up more often lately |
15:27:10 | FromDiscord | <haxscramper> yes, once you know about it |
15:27:18 | FromDiscord | <haxscramper> then you want to put it everywhere |
15:27:25 | FromDiscord | <haxscramper> it's like macros |
15:27:52 | FromDiscord | <haxscramper> once you start using it to solve some specific kind of issues it is almost impossible to get back |
15:28:24 | FromDiscord | <enthus1ast> nim has replaced toml in my monitoring system, a LOT less configuration |
15:28:46 | FromDiscord | <enthus1ast> so it was worth it, even if i had to use json for serialisation |
15:29:26 | FromDiscord | <enthus1ast> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/885547194114015262): nim(s) has replaced toml in my monitoring system, a LOT less configuration |
15:30:04 | FromDiscord | <enthus1ast> +1 |
15:35:35 | FromDiscord | <enthus1ast> when i look at the implementation of fromLit it seems quite doable (for me ;) ) to implement the stuff i need |
15:35:57 | FromDiscord | <enthus1ast> but i guess there are zillions of corner cases |
15:44:05 | * | mdbauman_ joined #nim |
15:47:07 | * | mdbauman quit (Ping timeout: 252 seconds) |
15:53:24 | FromDiscord | <haxscramper> `cast(uncheckedAssign)` is single best thing that happened for serialization |
15:53:56 | FromDiscord | <haxscramper> The main issue with pnode deserialization were handling discriminant objects |
15:54:09 | FromDiscord | <haxscramper> Well, not "singel best thing", but it is pretty good |
16:05:30 | arkanoid | can I mix importc and importcpp in same project? |
16:07:09 | FromDiscord | <treeform> yes, as far as I understand it, importcpp is just a different calling convention. |
16:07:53 | FromDiscord | <treeform> it does not have anything to do with cpp, it just says `a.proc(b, c)` instead of `proc(a, b, c)` |
16:09:02 | arkanoid | I've already wrapped the C version of a library and it is working, but the C++ version has handy proxy objects that could improve the nim interface. Unsure about the payoff |
16:20:41 | FromDiscord | <haxscramper> having `importcpp` implicitly promotes file to use `C++` compiler |
16:21:16 | FromDiscord | <haxscramper> `type a {.importcpp.} = object` compiled with `nim c file.nim` fails with `hidden symbol `\_Z13systemInit000v' isn't defined`-`execution of an external program failed\: 'g++ -o /tmp/asdfasdf\` |
16:21:20 | FromDiscord | <haxscramper> g++ |
16:25:21 | FromDiscord | <reilly> Does Nim provide a way of typing a proc argument based on whether or not a type implements a particular set of procs? |
16:28:23 | FromDiscord | <reilly> So, say I want a proc to accept any type so long as that type has the procs `proc a(x: T): int` and `proc b(x: T, y: int): string`. |
16:30:29 | FromDiscord | <reilly> You can just use a generic and the compiler will complain when you try and use an invalid type, but nimsuggest unhelpfully points the blame at the proc itself, and not the call that's causing the problem. |
16:30:59 | FromDiscord | <cabboose> wait what |
16:31:05 | arkanoid | I'm getting error with "@[myEnumValue][0].unsafeAddr", but "let foo = @[myEnumValue]\nfoo[0].unsafeAddr" works. I've been trying with parenthesis here and there but still returns error. How's the grammar here? |
16:31:35 | FromDiscord | <reilly> I mean, it does complain about a "generic/template instantiation from here" but that doesn't make it immediately obvious what the problem is. |
16:32:14 | FromDiscord | <cabboose> arkanoid does wrapping the seq in brackets create a tuple or does it still evaluate as a seq? |
16:33:02 | FromDiscord | <cabboose> @reilly I mean I don't event understand what you are asking |
16:33:06 | FromDiscord | <cabboose> I am probably too cooked and tired |
16:33:08 | FromDiscord | <cabboose> I should really study |
16:33:12 | FromDiscord | <cabboose> but medicine is boring |
16:33:41 | FromDiscord | <cabboose> @reilly can you provide code? |
16:33:59 | arkanoid | cabboose: it's still a seq |
16:34:01 | FromDiscord | <cabboose> In reply to @arkanoid "I'm getting error with": hahaha I didn't see you already said you tried with paranthesis; i'm definitely too tired |
16:34:12 | FromDiscord | <reilly> Yeah, it's kind of hard to explain well, I think. I've actually thought about it a little more after I wrote that and realized it's not really necessary, so don't worry about it. |
16:35:09 | arkanoid | the error I'm getting is: Error: expression has no address |
16:35:36 | arkanoid | seems like the address of the seq can't be acquired on same line |
16:35:44 | FromDiscord | <cabboose> Yeah it's not a reference, it doesn't really have a address |
16:35:48 | FromDiscord | <cabboose> because its a enum |
16:35:53 | FromDiscord | <cabboose> right? |
16:36:30 | FromDiscord | <Rika> In reply to @reilly "Does Nim provide a": yes but its experimental |
16:36:41 | FromDiscord | <Rika> concepts i believe will do what you want |
16:37:13 | FromDiscord | <Rika> docs are on `manual_experimental` |
16:39:39 | FromDiscord | <cabboose> In reply to @arkanoid "seems like the address": Yeah I wonder if the building of the seq gets optimised out so you are just left trying to get the ref to a enum value |
16:40:07 | FromDiscord | <cabboose> But if you assign it then it builds the seq and you actually have a address in memory that has that assignment |
16:40:28 | FromDiscord | <cabboose> I am not making sense to myself |
16:41:26 | FromDiscord | <cabboose> sent a code paste, see https://play.nim-lang.org/#ix=3yo2 |
16:43:17 | FromDiscord | <cabboose> or maybe even `@[MyEnumValue][0].unsafeAddr` still wouldn't work because without doing an assignment you aren't reserving any memory that would get referenced to on runtime and the compiler tries to evaluate that on compilation |
16:44:24 | FromDiscord | <reilly> In reply to @Rika "docs are on `manual_experimental`": I had no idea this existed! |
16:44:32 | FromDiscord | <Rika> i mean |
16:44:36 | FromDiscord | <Rika> its experimental |
16:44:58 | FromDiscord | <Rika> so if you're writing library code or prod code its not really something you'd use |
16:46:29 | * | jjido joined #nim |
16:47:02 | FromDiscord | <cabboose> Concepts are too much for me. Macros was enough of a hurdle to get (although in hindsight they are much simpler despite their verbosity) |
16:51:57 | arkanoid | cabboose: yeah, probably |
16:52:22 | arkanoid | I still have to find and use for concepts. What would you use it for? |
16:52:54 | arkanoid | I mean, I got the meaning, it's something like typeclasses in haskell |
16:54:38 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
17:01:00 | arkanoid | do you know if there's a nim lib proc that splits "http://user:pass@url/path" into @[http,user,pass,url,path] ? |
17:01:35 | FromDiscord | <cabboose> https://github.com/treeform/urlly has really good parsing afaik |
17:01:36 | nrds | <R2D299> itHub: 7"Uri and Url parsing for Nim for C and JS backend. Similar api to Window.location." |
17:11:43 | arkanoid | yeah! thanks treeform |
17:18:44 | arkanoid | I'm getting "object constructor needs an object type" and I don't know what I'm doing wrong |
17:23:21 | arkanoid | play.nim-lang.org is down? |
17:24:36 | FromDiscord | <Rika> yed |
17:24:36 | FromDiscord | <Rika> yes |
17:24:44 | arkanoid | I'm getting "type expected" and "object constructor needs an object type" on "initOnvif" call here https://termbin.com/l5ek |
17:24:48 | FromDiscord | <cabboose> Does it have something to do with the nim update lol |
17:25:10 | FromDiscord | <Rika> no |
17:26:05 | FromDiscord | <Rika> `host: purl...` -> `host = purl` |
17:26:08 | FromDiscord | <Rika> same with others |
17:26:33 | arkanoid | oh dear |
17:26:43 | arkanoid | shame on me |
17:28:17 | arkanoid | thanks |
17:28:23 | * | rockcavera quit (Remote host closed the connection) |
17:31:41 | FromDiscord | <aleclarson> any way to tell nim "hey this proc is side-effect free" even though `{.noSideEffect.}` says `'myProc' can have side effects` |
17:31:47 | FromDiscord | <aleclarson> ? |
17:32:03 | FromDiscord | <cabboose> Lying is bad |
17:32:23 | FromDiscord | <aleclarson> i've no choice, the proc calls into node.js so i can't enforce it |
17:32:29 | FromDiscord | <aleclarson> but the library i'm using wants a side-effect free proc |
17:32:47 | FromDiscord | <Rika> what part has side effects? |
17:32:53 | FromDiscord | <Rika> of the proc with side effects |
17:33:05 | FromDiscord | <aleclarson> the part that calls into node.js |
17:33:12 | FromDiscord | <cabboose> You can always use cast |
17:33:43 | FromDiscord | <aleclarson> (edit) "the part that calls into node.js ... " added "(but in reality, no side effects will be made)" |
17:33:50 | FromDiscord | <cabboose> sent a code paste, see https://play.nim-lang.org/#ix=3yop |
17:33:58 | FromDiscord | <aleclarson> oh interesting |
17:34:35 | FromDiscord | <cabboose> But your nose will grow 🤥 (jk) |
17:35:53 | FromDiscord | <aleclarson> i'm fine with a squidward nose tbh |
17:37:50 | FromDiscord | <cabboose> https://media.discordapp.net/attachments/371759389889003532/885579764549685298/5mexy4.png |
17:38:46 | FromDiscord | <leorize> not at the moment, a proper impl has to be done in nightlies which I haven't found the time to work on |
17:39:43 | FromDiscord | <leorize> I think iffy have a fork of my setup-nim that supports versioning via the current tags system, so you can try that one out. |
17:41:23 | FromDiscord | <Recruit_main707> In reply to @cabboose "": the compiler must obey me, i know whats better, until there is a sentinent compiler, i decide |
17:43:13 | FromDiscord | <cabboose> sent a code paste, see https://play.nim-lang.org/#ix=3yot |
17:43:35 | FromDiscord | <haxscramper> `{.push: overflowChecks:off.}` |
17:43:40 | FromDiscord | <haxscramper> and 8+ checks |
17:43:47 | FromDiscord | <haxscramper> also `uncheckedAssign` |
17:44:09 | FromDiscord | <haxscramper> how to write a nuclear bomb in nim under 1 minute |
17:44:11 | FromDiscord | <cabboose> Mate we were playing with sticks and you brought a sword |
17:44:21 | FromDiscord | <haxscramper> no, sword is like |
17:44:24 | FromDiscord | <haxscramper> `import compiler` |
17:44:29 | FromDiscord | <haxscramper> road to madness |
18:20:57 | FromDiscord | <aleclarson> In reply to @cabboose "": lol |
18:32:25 | * | rockcavera joined #nim |
18:32:25 | * | rockcavera quit (Changing host) |
18:32:25 | * | rockcavera joined #nim |
18:38:01 | * | vicfred joined #nim |
18:54:16 | FromDiscord | <ynfle (ynfle)> What does the error `Error: expression 'block: ...' has no type (or is ambiguous)` mean? |
18:57:11 | * | max22- quit (Quit: Leaving) |
18:58:23 | FromDiscord | <Rika> The block doesn't "return" anything but the left hand side expects something |
18:59:20 | * | jjido joined #nim |
19:01:17 | FromDiscord | <Varriount> @Zevv I broke NPeg. Apparently my grammar is too large for the computedGoto |
19:03:38 | FromDiscord | <Varriount> sent a code paste, see https://play.nim-lang.org/#ix=3yoY |
19:04:05 | FromDiscord | <ynfle (ynfle)> @Rika I don't think it should expect something... hmmm... I'm not sure |
19:09:06 | arkanoid | do you know if there's a lib proc to turn an uncheckedArray + int size into a seq? |
19:14:29 | FromDiscord | <Rika> You must copy in such case |
19:15:10 | FromDiscord | <Varriount> arkanoid: `@cast[array[type, N](uncheckedArray)` might work. |
19:15:25 | * | max22- joined #nim |
19:15:38 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
19:15:42 | FromDiscord | <Varriount> Or wait, that won't work if `N` isn't static. |
19:17:10 | FromDiscord | <haxscramper> There is no safe way to do this, since internal structure of a `seq` is considered an implementation detail |
19:17:39 | FromDiscord | <haxscramper> Also seqs are subject to garbage collection, so it might be a little more involved than just constructing object |
19:18:51 | FromDiscord | <haxscramper> The safest way would be to copy data ... that is slow, but I don't think stdlib provides anything to deal with this |
19:33:10 | FromDiscord | <Varriount> In reply to @haxscramper "The safest way would": You can use one of the unsafe copying mechanisms, but that will only work for types that aren't or don't contain references. |
19:33:27 | * | supakeen quit (Remote host closed the connection) |
19:33:50 | * | supakeen joined #nim |
19:35:12 | FromDiscord | <Varriount> @Zevv Zevv: Also, it seems that when I enable `npegTrace`, my program just crashes somewhere in the parsing code (this was in an attempt to debug a "backtrace depth exceeded" error). |
19:44:00 | FromDiscord | <aleclarson> sent a code paste, see https://play.nim-lang.org/#ix=3yp8 |
19:44:12 | FromDiscord | <aleclarson> (edit) "https://play.nim-lang.org/#ix=3yp8" => "https://play.nim-lang.org/#ix=3yp9" |
19:46:07 | FromDiscord | <haxscramper> this is not an error, it is a warning |
19:46:59 | FromDiscord | <haxscramper> also, please, don't raise `Defect` of all things |
19:47:32 | FromDiscord | <aleclarson> does it matter that i raise Defect? \:P |
19:48:25 | FromDiscord | <haxscramper> with `--panics:on` defects can't be caught, raising defect is probably second worst thing, with first one being `Exception` root - it does not provide any meaning whatsoever |
19:48:34 | FromDiscord | <haxscramper> There are things like `KeyError`, or `ValueError` |
19:49:01 | FromDiscord | <haxscramper> And `Cannot prove that 'result' is initialized.` is probably prover being stupid |
19:49:07 | FromDiscord | <haxscramper> this has been a warning for as long as I can remember |
19:49:18 | FromDiscord | <haxscramper> And I can bet it will never be turned into an error |
19:49:36 | FromDiscord | <aleclarson> good to know thx! |
19:49:58 | FromDiscord | <haxscramper> But back to `Defect` - I personally recommend never, ever touching it in any form |
19:50:03 | FromDiscord | <haxscramper> Especially raising it in your code |
19:55:45 | FromDiscord | <haxscramper> In reply to @aleclarson "good to know thx!": https://forum.nim-lang.org/t/7983#52131 |
19:56:52 | FromDiscord | <haxscramper> If you need more thorough reasoning about `Defect` |
20:24:42 | FromDiscord | <ant1fact> In general, which approach is faster: strscans, parseutils or regex? |
21:17:15 | FromDiscord | <treeform> I think it always depends, you can just measure things with https://github.com/treeform/benchy |
21:17:17 | nrds | <R2D299> itHub: 7"Benchmarking." |
21:18:36 | FromDiscord | <treeform> my gut feeling that writing your own little parser would always be faster... that just walks the characters and populates the fields. |
21:51:33 | arkanoid | is there a shortcut for float countup for loops? like "for i in countup(0.0, 1.0, 0.2)" |
21:52:42 | arkanoid | system.countup likes ordinal only |
21:54:41 | NimEventer | New post on r/nim by G_Lasso: Drawim: a simple drawing library in Nim, inspired by p5js, see https://reddit.com/r/nim/comments/pl7k4b/drawim_a_simple_drawing_library_in_nim_inspired/ |
21:55:28 | FromDiscord | <Elegantbeef> Seems liike there is not arkanoid so time to make your own 😀 |
21:55:44 | arkanoid | sure, it's trivial |
21:55:56 | arkanoid | but quite surprised about the lack of it in system |
21:57:50 | FromDiscord | <Elegantbeef> Well it's relatively specialized as i dont think i've ever used that 😀 |
22:07:43 | arkanoid | well counting from 0.0 to 1.0 it quite important in many calculations. Geometry for example |
22:36:24 | * | Vladar quit (Quit: Leaving) |
22:41:36 | FromDiscord | <Varriount> arkanoid: There's no float countup because it's not accurate. |
22:44:49 | FromDiscord | <Varriount> arkanoid: For example, as I understand it, `var x = 0.0; for _ in 0..100: x += 20.0` will be different from `var x = 0.0; for _ in 0..20: x += 100.0` |
22:51:50 | FromDiscord | <RattleyCooper> In reply to @arkanoid "well counting from 0.0": Yeah, but counting up from 0.0 to 1.0 takes forever |
22:52:15 | * | audiophile_ joined #nim |
22:52:45 | arkanoid | Varriount sure, just like any other float operation |
22:53:44 | FromDiscord | <jos> is it expected that the destructor won't be called unless using the new operator? i don't understand why a ref type and new are being treated different |
22:53:46 | FromDiscord | <jos> using refcounting gc btw |
22:53:50 | arkanoid | interpolation, lerping, and animations in general really like 0.0 to 1.0 stuff |
22:54:06 | FromDiscord | <Varriount> @RattleyCooper Reminds me of the Mathmagician's staircase to infinity in The Phantom Tollbooth |
22:54:10 | arkanoid | RattleyCooper, that's why I added a third argument |
22:59:04 | * | stkrdknmibalz joined #nim |
22:59:47 | FromDiscord | <RattleyCooper> In reply to @arkanoid "<@408056314342932491>, that's why I": Yeah I'm just making a bad joke 😛 |
23:04:34 | FromDiscord | <jos> is there a way to have `type Test = ref object` have a destructor? |
23:04:55 | FromDiscord | <jos> when using one of the refcounting gcs |
23:05:24 | FromDiscord | <Elegantbeef> The destructor should work but it requires the GC to kick in afaik |
23:05:52 | FromDiscord | <jos> i can't even declare one because i get this error |
23:05:53 | FromDiscord | <jos> prog.nim(19, 1) Error: signature for '=destroy' must be proc[T: object](x: var T) |
23:05:55 | FromDiscord | <Elegantbeef> So it doesnt behave predictably |
23:06:04 | FromDiscord | <jos> type Test = ref object↵↵proc `=destroy`(test: var Test) = ↵ echo "destroy called" |
23:06:23 | FromDiscord | <jos> if there are no circular refs i would expect it to be predictable from what i read about ORC |
23:06:28 | FromDiscord | <jos> but i can't even declare it :S |
23:06:54 | FromDiscord | <jos> if i do `type Test = ref object` -> `type Test = object`, then that error goes away |
23:07:03 | FromDiscord | <jos> but then i have to manually heap allocate all my Test's with new() |
23:07:13 | FromDiscord | <jos> and i have to use `ref` whenever i pass em around |
23:07:19 | FromDiscord | <jos> i may be misunderstanding something tho |
23:09:04 | FromDiscord | <Elegantbeef> I havent used destructors so i could be wrong that they work with `ref` |
23:09:36 | * | vicfred quit (Quit: Leaving) |
23:11:13 | FromDiscord | <Elegantbeef> It does work with distincts |
23:12:38 | arkanoid | how can I wait keyboard arrow press in terminal? |
23:12:45 | arkanoid | without waiting for following enter |
23:16:44 | FromDiscord | <jos> @ElegantBeef is a distinct like a unique ptr in other langs? |
23:17:18 | FromDiscord | <Elegantbeef> Nah distinct in nim is a type system unique type |
23:17:42 | FromDiscord | <Elegantbeef> `type NotInt = distinct int` `assert NotInt isnot int` |
23:22:35 | FromDiscord | <jos> i don't really understand, does this help me address the same use case as a ref somehow? |
23:22:48 | FromDiscord | <jos> from what i'm reading it's just a typedef that can't be coerced but idk |
23:24:08 | * | max22- quit (Remote host closed the connection) |
23:24:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ypQ |
23:24:16 | FromDiscord | <Elegantbeef> But i dont know the proper way about this |
23:24:23 | FromDiscord | <Elegantbeef> So probably disregard me |
23:26:38 | FromDiscord | <jos> oh interesting |
23:26:40 | FromDiscord | <jos> that could work |
23:26:41 | FromDiscord | <jos> thanks |
23:26:43 | FromDiscord | <jos> (edit) "thanks" => "thanks!" |
23:27:25 | FromDiscord | <Elegantbeef> You will have to make your own properties to access the fields which kinda sucks, but like i said i dont know if there is a better way \:D |
23:27:34 | * | audiophile_ quit (Quit: Default Quit Message) |
23:28:54 | FromDiscord | <leorize> `{.borrow: `.`.}` to borrow all the fields |
23:29:14 | * | audiophile_ joined #nim |
23:29:29 | FromDiscord | <Elegantbeef> Ah yea that makes sense |
23:35:09 | FromDiscord | <jos> how do i construct the distinct type? |
23:36:26 | FromDiscord | <jos> is there a way to use the nice Type(field, field, field) syntax but still construct a type as a ref? |
23:36:43 | FromDiscord | <jos> i see new(Type) works with my distinct type |
23:36:53 | FromDiscord | <jos> but the other syntax doesn't work |
23:37:18 | FromDiscord | <leorize> you construct the original type then convert it to the distinct one |
23:37:26 | FromDiscord | <Elegantbeef> you can do `Inner(Test(a: 100))` |
23:37:29 | FromDiscord | <jos> oh nice! |
23:37:31 | FromDiscord | <jos> i like that 🙂 |
23:37:37 | FromDiscord | <jos> nim is so cool |
23:37:43 | FromDiscord | <jos> i can't wait until it supports incremental compilation :^) |
23:37:58 | FromDiscord | <Elegantbeef> I'd expect most people would find what we had to do more annoying than cool P |
23:38:51 | FromDiscord | <jos> true but in a lot of other languages you're just screwed :^) |