00:15:49 | FromDiscord | <Elegantbeef> Does anyone know if it's possible to have the `static` scope run as if it was running inside a `nim e` instead of for the OS you're compiling for? |
00:41:38 | * | dithpri quit (Quit: '); DROP TABLE Users;--) |
00:59:11 | * | Figworm joined #nim |
01:17:13 | * | cyraxjoe joined #nim |
01:17:25 | * | algae quit (Ping timeout: 240 seconds) |
01:17:40 | FromDiscord | <demotomohiro> I don't know how to do it but this code do similar thing↵`const foo = staticExec("nim e mycode.nim")` |
01:23:16 | FromDiscord | <Patitotective> Can I get the nim filename in this command? I want to add an extension to the output files https://media.discordapp.net/attachments/371759389889003532/929545829147107388/unknown.png |
01:24:11 | FromDiscord | <Patitotective> Like |
01:24:47 | FromDiscord | <Patitotective> (edit) "Like" => "sent a code paste, see https://play.nim-lang.org/#ix=3LzA" |
01:25:46 | * | Figworm quit (Quit: Figworm) |
01:29:34 | FromDiscord | <impbox [ftsf]> In reply to @Patitotective "Can I get the": using config.nims you can |
01:30:21 | FromDiscord | <Patitotective> how? |
01:30:22 | * | MightyJoe joined #nim |
01:30:26 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3LzC |
01:30:50 | FromDiscord | <impbox [ftsf]> -o is optional, so i default to using the projectName |
01:31:17 | * | cyraxjoe quit (Ping timeout: 240 seconds) |
01:33:09 | FromDiscord | <Patitotective> hmm |
01:33:15 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LzD |
01:33:27 | FromDiscord | <impbox [ftsf]> ahh import std/compilesettings |
01:33:42 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/compilesettings.html |
01:35:52 | * | MightyJoe quit (Quit: I'm out!) |
01:37:31 | * | cyraxjoe joined #nim |
01:40:22 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LzE |
01:43:33 | FromDiscord | <Patitotective> yea, it works if i do tht |
01:43:35 | FromDiscord | <Patitotective> (edit) "tht" => "that" |
01:59:54 | * | algae joined #nim |
02:03:47 | * | bkay joined #nim |
02:04:23 | * | beshr quit (Ping timeout: 256 seconds) |
02:05:07 | * | noeontheend joined #nim |
02:29:38 | * | neurocyte09172 joined #nim |
02:31:25 | * | neurocyte0917 quit (Ping timeout: 240 seconds) |
02:31:25 | * | neurocyte09172 is now known as neurocyte0917 |
03:26:13 | FromDiscord | <gogolxdong (liuxiaodong)> Does anyone know Brave Browser? |
03:31:48 | FromDiscord | <Rika> Yes, why |
03:35:38 | FromDiscord | <gogolxdong (liuxiaodong)> Just curious and want to say it's a good production , I'm migrating from chrome to brave across the board. |
03:36:51 | FromDiscord | <Rika> I personally dislike the company |
03:37:06 | FromDiscord | <Rika> I would really just recommend Firefox over anything… |
03:37:07 | FromDiscord | <gogolxdong (liuxiaodong)> We'd like to make a similiar one but support IPFS natively especially on mobile phone. |
03:37:10 | FromDiscord | <Elegantbeef> I like the many issues they have |
03:37:18 | FromDiscord | <Rika> In reply to @Elegantbeef "I like the many": What lol |
03:37:30 | FromDiscord | <Elegantbeef> "Privacy first browser" which requires phoning home |
03:37:53 | FromDiscord | <Rika> Yeah lol |
03:38:23 | FromDiscord | <Rika> That weird currency thing they have too |
03:38:33 | FromDiscord | <Elegantbeef> https://github.com/brave/brave-browser/issues/19125 is a fun github issue |
03:39:11 | FromDiscord | <Elegantbeef> Yea i'm just using firefox |
03:41:45 | FromDiscord | <Rika> How fun |
03:50:17 | * | sagax quit (Ping timeout: 240 seconds) |
03:53:11 | FromDiscord | <gogolxdong (liuxiaodong)> Though our testing of decentralized sharing cases for Brave desktop shows it did good job, there is only public IPFS gateway to open file files/directories on mobile phone which is somewhat slower than native IPFS protocol. |
03:57:20 | * | arkurious quit (Quit: Leaving) |
04:02:21 | * | anadahz quit (Remote host closed the connection) |
04:02:40 | * | anadahz joined #nim |
04:09:43 | FromDiscord | <gogolxdong (liuxiaodong)> Most of public gateway are blocked by GFW. |
04:12:58 | * | algae quit (Quit: WeeChat 3.4) |
04:35:01 | * | noeontheend quit (Ping timeout: 240 seconds) |
05:26:15 | * | kayabaNerve_ joined #nim |
05:41:38 | NimEventer | New Nimble package! conventional_semver - Calcualte the next semver version given the git log and previous version, see https://gitlab.com/SimplyZ/conventional_semver |
06:16:06 | FromDiscord | <Bung> @PMunch please check this when you feel free https://github.com/PMunch/nimlsp/pull/109 |
08:58:23 | * | Gustavo6046 quit (Quit: Leaving) |
09:14:29 | * | jjido joined #nim |
09:59:54 | NimEventer | New post on r/nim by TheDarkMode: How to use JS to make a front end, see https://reddit.com/r/nim/comments/rzofbm/how_to_use_js_to_make_a_front_end/ |
10:27:52 | * | lumo_e joined #nim |
10:51:54 | FromDiscord | <Isofruit> In reply to @Rika "I would really just": I use firefox on desktop any time of the week.↵Firefox mobile though feels hard-core like an abandoned product with how badly it performs on my (admittedly potato) phone |
10:52:07 | FromDiscord | <Rika> Ah mobile yeah |
10:52:11 | FromDiscord | <Rika> Pretty eh |
10:52:23 | FromDiscord | <Rika> Performance aside even, it just feels dated |
10:52:41 | FromDiscord | <Isofruit> If my side-project loads 3 times faster on brave than it does on FF then there are some fundamental engine issues |
10:53:07 | FromDiscord | <Rika> Probably |
10:54:25 | FromDiscord | <Isofruit> I've been contemplating which Chromium Browser to use on mobile until FF performance rises, so far brave seems alright |
10:54:51 | FromDiscord | <Isofruit> Then again, I don't do anything even remotely important on my phone if I can help it, particularly over the browser |
10:57:07 | FromDiscord | <Rika> I’m almost always outside the apartment so I use my phone mega heavily |
10:57:18 | FromDiscord | <Rika> I have two power banks always in my bag usually charged |
11:02:22 | FromDiscord | <Isofruit> Active a lot?↵Yeah not quite the same on my end, since the HO days I'm only on mobile on my way to sports or visiting someone |
11:04:00 | * | PMunch joined #nim |
11:06:32 | FromDiscord | <Rika> In reply to @Isofruit "Active a lot? Yeah": Yeah |
11:06:40 | FromDiscord | <Rika> I don’t really like staying in the house |
11:06:54 | FromDiscord | <Rika> You can imagine how COVID was for me when it was still lockdown for me |
11:09:05 | FromDiscord | <Isofruit> In reply to @Rika "You can imagine how": Ooooooooff, that must've been really damn rough, my condolences. |
11:09:34 | FromDiscord | <Isofruit> What you normally doing? Going for walks/coffee? |
11:10:02 | FromDiscord | <Isofruit> Are you the stock foto of a developer sitting on a lawn in a sunny day, back against the tree, enjoying the life? 😄 |
11:10:26 | FromDiscord | <Rika> A lot of things, cycling around, going to the same malls I usually go to, parks, river sides, literally “throw a dart at the map and let’s see” |
11:10:50 | FromDiscord | <Rika> In reply to @Isofruit "Are you the stock": Nah I don’t develop in these places, too depressing to do |
11:15:18 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
11:22:31 | FromDiscord | <Rika> Ah, but I do read documentation like a book |
11:22:34 | FromDiscord | <Rika> Yes I’m a weirdo |
11:23:35 | FromDiscord | <Isofruit> That is legitimately a habit I envy you for, when I try reading docs without already having some level of connection to a given library, my brain doesn't comprehend the words fully. I see them, I get a rough idea, but it's not clicking anywhere |
11:28:04 | FromDiscord | <Isofruit> On a more channel related note:↵Is anyone else using prologue? If so, do you guys also have the issue that, when there is an exception and Prologue hands you the exception traceback, you don't see the exception-type ? |
11:38:45 | * | krux02 joined #nim |
11:49:57 | PMunch | @Isofruit, just wait until I have my eEink laptop up and running. I'll be chilling in the sun programming like a damn maniac! |
11:50:32 | FromDiscord | <Isofruit> Too much power! |
11:50:47 | FromDiscord | <Isofruit> He will be able to code and charge up with some Vitamin D |
11:51:18 | FromDiscord | <Isofruit> The world can not endure somebody developing and being in a healthy environment! |
11:54:51 | PMunch | Jokes on you, I already drink my Tran so I'm full of vitamin D despite not seeing the sun for half the year! |
11:54:53 | FromDiscord | <Isofruit> ...if I have an error, is there a way to see which package/module its defined in so I can import it and use it in a catch statement? |
11:55:07 | FromDiscord | <Isofruit> (edit) "error," => "Exception," |
11:55:08 | PMunch | grep? |
11:55:34 | FromDiscord | <Isofruit> curses, the one linux tool I have not yet acclimatized to despite knowing it is useful |
11:55:39 | PMunch | :P |
11:55:59 | PMunch | `grep -Hnr "MyCoolException" ~/.nimble/pkgs` |
11:56:05 | PMunch | That should show you where it is |
11:56:11 | PMunch | Or rather everywhere it is mentioned |
11:56:41 | PMunch | I guess you might want to throw on a "MyCoolExcption =" to find the definition |
11:56:45 | FromDiscord | <Isofruit> Ahah! "NotFoundError" stems from norm! |
11:57:08 | PMunch | Some times the most basic tools will yield you the greatest power |
11:58:18 | FromDiscord | <Isofruit> Thanks for the command! I'll... one of these days I'll invest the time to actually learn grep |
11:58:46 | PMunch | Once you get used to it you will wonder how you ever got by without it |
11:59:10 | FromDiscord | <congusbongus> rg is pretty cool |
11:59:42 | PMunch | By the way, that command explained is "H: with filenames, n: with line numbers, r: recursive through folder" |
12:00:22 | PMunch | @congusbongus, rg? |
12:00:30 | FromDiscord | <Rika> Ripgrep |
12:08:51 | FromDiscord | <planetis> Hey, is it safe for c code generated by nim to do this\: `int test(int x) { return &x }` ? |
12:11:48 | FromDiscord | <federico3> is there a way to show the code generated by templates? |
12:13:25 | FromDiscord | <planetis> if not expandmacros then you could get it if you use it wrong and the compiler outputs an error with the expanded code |
12:14:47 | FromDiscord | <el__maco> that code doesn't look particularly "safe" |
12:16:12 | FromDiscord | <planetis> well ok sure but can it lead to undefined behavior if used incorrectly |
12:16:55 | FromDiscord | <el__maco> what would be a correct use of that 🤔 |
12:17:06 | FromDiscord | <planetis> well its nim compilers job to make sure the code is safe but I am trying to figure if lent return type with .bycopy pragma produce faulty code |
12:18:14 | FromDiscord | <el__maco> `x` doesn't exist anymore when the function returns. Using that pointer would be a problem |
12:18:36 | FromDiscord | <planetis> ok thank you, thats what i thought as well |
12:19:32 | FromDiscord | <el__maco> not sure what compilers do in this situation, since depending on the calling convention `x` might not be anywhere in the memory to begin with |
12:19:34 | FromDiscord | <planetis> btw I ran that code with asan and it didn't complain, it confused me... |
12:20:21 | FromDiscord | <planetis> i had -fsanitize=address,undefined |
12:22:04 | FromDiscord | <Rika> It’s probably some hacky specification that says that it’s valid |
12:24:27 | FromDiscord | <planetis> ill report a bug anyway |
12:25:25 | * | lumo_e quit (Ping timeout: 240 seconds) |
12:27:56 | FromDiscord | <el__maco> sent a code paste, see https://play.nim-lang.org/#ix=3LD2 |
12:28:37 | FromDiscord | <el__maco> seems like the default calling convention puts arguments on stack then 🤔 |
12:35:20 | FromDiscord | <Isofruit> Is there a lazy way around defining init procs? |
12:35:53 | FromDiscord | <Rika> Third party package |
12:36:04 | FromDiscord | <Rika> Beef made it because of course he did |
12:36:22 | FromDiscord | <Isofruit> sent a long message, see http://ix.io/3LD5 |
12:37:15 | FromDiscord | <Isofruit> What's the name? |
12:37:19 | FromDiscord | <Isofruit> (edit) "long message," => "code paste," | "http://ix.io/3LD5" => "https://play.nim-lang.org/#ix=3LD7" |
12:37:28 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3LD7" => "https://play.nim-lang.org/#ix=3LD8" |
12:37:49 | FromDiscord | <Rika> Constructor |
12:38:10 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3LD8" => "https://play.nim-lang.org/#ix=3LD9" |
12:38:37 | FromDiscord | <Isofruit> Let me pray silently that he doesn't view Constructor like a child |
12:38:41 | FromDiscord | <Isofruit> (edit) "a" => "his own" |
12:39:01 | FromDiscord | <Isofruit> (edit) "like" => "as if it were" |
12:39:06 | FromDiscord | <Isofruit> There, better expressed |
12:41:23 | FromDiscord | <Isofruit> That looks really nice, and saves me writing like 50+ boilerplate constructors |
13:08:25 | FromDiscord | <Isofruit> Another question, is there perhaps a way to print the exception's package?↵I'm in an issue with xflywind about the thing with printing an error type. I think it'd be even more helpful to not just log the exception's type as a string, but also the package it comes from for easy importing, saves the user having to grep their nimble repo themselves. |
13:08:36 | FromDiscord | <Isofruit> (edit) "print the" => "echo an" |
13:27:58 | * | lumo_e joined #nim |
13:35:06 | FromDiscord | <xflywind> Sorry, I have no idea. But you can echo the package of specific type at compile time. |
13:35:36 | FromDiscord | <krisppurg> Is it weird to have a case statement inside a case statement? |
13:36:35 | * | jjido joined #nim |
13:36:40 | FromDiscord | <xflywind> In reply to @flywind "Sorry, I have no": https://play.nim-lang.org/#ix=3LDs |
13:37:45 | FromDiscord | <xflywind> I don't know a way to detect that at runtime. |
13:48:44 | FromDiscord | <Isofruit> Hmm not without making an entire package out of it that makes a map of exceptiontype-package name at compile time and calls that at runtime, which would be shooting with cannons on sparrows |
13:56:44 | FromDiscord | <xflywind> I agree |
14:13:59 | FromDiscord | <Patitotective> How can I make Nim generates a file with extension on Linux? Like, what's the proper extension? `.so`, `.lib`? |
14:22:43 | FromDiscord | <federico3> is there any line profiler that generates charts & similar? |
14:24:50 | FromDiscord | <planetis> https://github.com/KDAB/hotspot ? |
14:24:54 | FromDiscord | <Rika> In reply to @Patitotective "How can I make": linux binaries do not have extensions |
14:26:43 | FromDiscord | <Patitotective> But it says it is a shared library, and shared libraries do have extensions (i think) |
14:28:57 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
14:30:41 | FromDiscord | <Rika> .so |
14:30:48 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LDN |
14:30:54 | FromDiscord | <Rika> yes |
14:32:13 | * | lumo_e quit (Ping timeout: 240 seconds) |
14:55:22 | * | lumo_e joined #nim |
14:56:26 | * | arkurious joined #nim |
14:59:22 | * | SebastianM joined #nim |
14:59:28 | FromDiscord | <federico3> thanks [planetis](https://matrix.to/#/@planetis:matrix.org) |
15:03:43 | SebastianM | Guys, I found that the latest build of nim in nightlies repo is from December 14. Whats going on? |
15:05:49 | FromDiscord | <federico3> [planetis](https://matrix.to/#/@planetis:matrix.org)\: do you use perf with it? Any way to add descriptive proc names to the output? |
15:06:46 | FromDiscord | <leorize> `--call-graph dwarf` |
15:07:21 | FromDiscord | <leorize> if hotspot's UI is not your jam, checkout FF profiler too\: https://profiler.firefox.com/docs/#/./guide-perf-profiling |
15:09:14 | * | SebastianM quit (Quit: Bye) |
15:09:28 | FromDiscord | <planetis> Works with perf, I compile with -g at the end. The names are mangled but I generally don't mind. Only problem are [] procs which I need to find out which one is which at the C file. |
15:13:25 | FromDiscord | <federico3> any way to do line profiling? |
15:17:29 | FromDiscord | <Saptak> what is the difference between ``div`` and ``/`` |
15:20:39 | FromDiscord | <Rosen> div is integer division |
15:27:58 | PMunch | SebastianM, hmm that is a bit peculiar |
15:29:41 | FromDiscord | <Saptak> In reply to @Rosen "div is integer division": what's the diffrence |
15:31:07 | FromDiscord | <Rosen> https://media.discordapp.net/attachments/371759389889003532/929759198563143700/unknown.png |
15:31:23 | FromDiscord | <Rosen> div outputs the integer division result while / will give you a float result |
15:32:39 | FromDiscord | <Saptak> Oo |
15:39:11 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LEe |
15:41:44 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LEg |
15:51:33 | FromDiscord | <Patitotective> it worked that way LOL↵im super smart or nim's super intuitive |
16:00:48 | FromDiscord | <Rika> why not both |
16:50:52 | FromDiscord | <leorize> it's due to github sorting, check these tags instead\: https://github.com/nim-lang/nightlies/releases?q=latest&expanded=true↵(<@709044657232936960_=53ebastian=4d=5b=49=52=43=5d>) |
17:09:18 | FromDiscord | <exelotl> I'm I'm doing a PR to fix a bug introduced in Nim 1.6, do I need to include [backport:1.6] ? |
17:09:24 | FromDiscord | <exelotl> (edit) "I'm" => "if" |
17:09:47 | FromDiscord | <Elegantbeef> Nah |
17:11:57 | FromDiscord | <exelotl> even though it's a PR into devel and the current "in progress" changelog says 1.8.x ? |
17:13:47 | FromDiscord | <Elegantbeef> Yes, you can ask for it to be backported |
17:16:51 | FromDiscord | <xflywind> In reply to @exelotl "if I'm doing a": it is recommended to do so. |
17:17:41 | FromDiscord | <xflywind> https://nim-lang.github.io/Nim/contributing.html#the-cmdgit-stuff-general-commit-rules |
17:18:52 | FromDiscord | <exelotl> so I say [backport:1.6] and add an entry to the 1.8 changelog, and somebody will correctly move it into the 1.6.4 changelog when the time comes? |
17:19:20 | FromDiscord | <xflywind> true |
17:20:14 | FromDiscord | <xflywind> that's what has been happening |
17:20:52 | FromDiscord | <exelotl> ok, thanks! |
17:23:07 | FromDiscord | <xflywind> the changelog will appear on tge release artcile: https://nim-lang.org/blog/2021/12/17/version-162-released.html |
17:23:10 | FromDiscord | <xflywind> you are welcome |
17:23:23 | FromDiscord | <Patitotective> Should I export a std library or should I re-import it? (Like from the submodule to the main module of a nimble package) |
17:23:36 | FromDiscord | <Elegantbeef> Purely up to you |
17:24:05 | FromDiscord | <Patitotective> But it doesn't affect efficiency, right? |
17:24:22 | FromDiscord | <Elegantbeef> It does not |
17:26:30 | FromDiscord | <Elegantbeef> The module should be typed once then reused, and code generated is non duplicated, so it should be good all round |
17:28:43 | * | qwr quit (Read error: Connection reset by peer) |
18:03:54 | nrds | <Wabby/freenode99> Is there a reason why issues are rarely labeled on the Nim repository? |
18:21:03 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/zL5 |
18:21:42 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LF8" => "https://play.nim-lang.org/#ix=3LF7" |
18:24:24 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LF9 |
18:24:49 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LF9" => "https://play.nim-lang.org/#ix=3LFa" |
18:24:55 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LFa" => "https://play.nim-lang.org/#ix=3LFb" |
18:25:18 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LFb" => "https://paste.rs/DC6" |
18:26:39 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LFe |
18:31:21 | FromDiscord | <Elegantbeef> `newCall(ident"PTable", ident"()", ident"as", ident"PTableTypes")` is just wrong in all regards |
18:31:34 | FromDiscord | <Elegantbeef> What is the code you want to generate written out as? |
18:32:25 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LFh |
18:32:32 | FromDiscord | <Patitotective> But those parenthesis doesn't seem to work in `newCall` |
18:32:41 | FromDiscord | <Elegantbeef> So then `nnkObjectConstr.newTree(ident"Ptable")` |
18:32:42 | FromDiscord | <Elegantbeef> Well of course not that's not a call |
18:33:06 | FromDiscord | <Patitotective> In reply to @Elegantbeef "`newCall(ident"PTable", ident"()", ident"as", ident": Yea, I'm not sure where to read about those procedures, docs doesn't seem to help |
18:33:19 | FromDiscord | <Patitotective> In reply to @Elegantbeef "So then `nnkObjectConstr.newTree(ident"Ptable")`": I'll try it later, thanks, I gtg |
18:33:49 | FromDiscord | <Elegantbeef> https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
18:33:50 | FromDiscord | <Elegantbeef> Read what i linked when you have time |
18:33:52 | FromDiscord | <Elegantbeef> It'll give you a basis on how to write macros |
18:49:50 | FromDiscord | <Professor Actual Factual> How does one create a memory aligned seq in nim like cpp `_mm_malloc`? |
18:56:44 | FromDiscord | <ynfle (ynfle)> @Patitotective Try using `macros.dumpTree` to see the ast (which is basically what it says in the article beef linked/wrote) |
19:15:01 | * | bkay quit (Ping timeout: 240 seconds) |
19:26:22 | * | jjido joined #nim |
19:41:17 | FromDiscord | <auxym> Anyone know if c2nim is supposed to support stdint types, eg `uint8_t`? It seems to be generating them as `uint8T` in nim, which isn't even valid nim... |
19:59:01 | FromDiscord | <Recruit_main707> afaik you can just do `type uint8T = uint8` and it should be fine |
20:00:59 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=3LFK |
20:01:53 | FromDiscord | <auxym> also c2nim seems to choke on `attribute ((packed))` annotations to struct typedefs |
20:02:06 | PMunch | @auxym, have you tried Futhark? |
20:03:00 | FromDiscord | <auxym> not yet, I do remember reading about it on the forums... how well does it handle a huge soup of macros? 😛 Trying to make minimal bindings for tinyusb |
20:04:48 | PMunch | Better than any of the alternatives in my testing |
20:05:01 | PMunch | It's the only C wrapper I've managed to wrap huge codebases in |
20:05:51 | PMunch | It doesn't do a great job at exposing macros you're supposed to be able to call yourself though. But it handles all the macros uses internally. |
20:08:20 | FromDiscord | <auxym> great! might give it a try! |
20:10:50 | PMunch | Just to be clear, I'm also the person who wrote Futhark, so my views of the library are obviously a bit coloured by that |
20:11:03 | PMunch | But just let me know if you need help :) |
20:11:20 | FromDiscord | <Elegantbeef> My biggest issue with futhark is it's biggest benefit 😛 |
20:11:31 | PMunch | Which is? |
20:11:35 | PMunch | That it requires Clang? |
20:11:50 | FromDiscord | <Elegantbeef> No that it doesnt emit `.nim` files |
20:11:57 | PMunch | It does though |
20:12:05 | FromDiscord | <Elegantbeef> I thought it didnt |
20:12:13 | PMunch | Just in a cache folder, because you're not supposed to ever have to look at them |
20:12:23 | FromDiscord | <Elegantbeef> Ah there we go |
20:12:27 | PMunch | It puts them in your nimcache :) |
20:12:36 | PMunch | So you can go have a look at them if you want to |
20:12:42 | FromDiscord | <Elegantbeef> So then i might use futhark on things more often |
20:12:52 | PMunch | But you shouldn't have to for what it's worth |
20:13:01 | * | Gustavo6046 joined #nim |
20:13:15 | PMunch | At least not once you're comfortable with how it wraps things |
20:13:18 | FromDiscord | <Elegantbeef> I prefer concrete definitions and if possible applying the idiomatic nim conventions on the imported procs |
20:14:58 | PMunch | Well Futhark is more about just making the C imports transparent |
20:15:41 | FromDiscord | <Elegantbeef> Yea i know easiest/fastest way to get the C-api into Nim |
20:15:46 | FromDiscord | <Elegantbeef> Not the most idiomatic one |
20:15:50 | PMunch | So you should build your stuff on top to give it better types and stuff. But that should call the underlying C procedures (you can make it zero-cost by using templates) so that if the underlying C code changes or updates you will have type conflicts |
20:17:45 | FromDiscord | <Elegantbeef> I know I know, I'm just odd and do not like that way |
20:18:15 | PMunch | Why not? |
20:19:06 | PMunch | What's better than just having the C types exactly as they appear in the C code and then get proper type mismatch error messages if the underlying code changes? |
20:20:26 | PMunch | I had a project that I had wrapped manually because I couldn't get c2nim or nimterop to work on it, even after about a week of trying with both (at work, so 8 hours a day). I wrote Futhark and wrapped it in minutes, and I was shocked(!) by the fact that my manual wrapper still worked because the type definitions had drifted a *lot* more than I had expected |
20:27:05 | PMunch | Futhark now keeps my types true to the C library, so if I have a type mismatch I will know. And Nim will generate objects that are actually the right size and fields at the correct offsets |
20:27:20 | PMunch | That's what I'm looking for in a C wrapper, a tool that wraps C |
20:27:40 | PMunch | And then I can build abstractions on top of the C library |
20:33:17 | FromDiscord | <Elegantbeef> I dont really touch C, so that's why i'm so odd here, the most i've touched C is the slow manual wrapping of the pico-sdk |
20:33:58 | FromDiscord | <Elegantbeef> I'm just an idiot that doesnt have interest in the tool wrappings since i'll have to idiomatically do it anyway before i'll be happy, but it means a majority of the sdk isnt wrapped since either i havent or someone hasnt asked for it |
20:38:15 | FromDiscord | <Michal Maršálek> Hi, why does this not work: https://play.nim-lang.org/#ix=3LH1? |
20:38:27 | FromDiscord | <Michal Maršálek> (edit) "https://play.nim-lang.org/#ix=3LH1?" => "https://play.nim-lang.org/#ix=3LH1 ?" |
20:39:13 | PMunch | @Elegantbeef, the thing is that with Futhark you can focus on only creating your high level stuff. It's so draining to have a nice idea just to spend an entire evening trying to get c2nim or nimterop to just read your god damn C header file |
20:39:52 | PMunch | @Michal_Maršálek, why do you use that `id` thing? |
20:42:24 | FromDiscord | <Michal Maršálek> I want to have a template/macro that creates a complex generic type, here I created a simple example in which the template is an identity. |
20:44:21 | FromDiscord | <leorize> type expression that uses generics won't work on return type declaration unless you use some tricks |
20:45:18 | FromDiscord | <Michal Maršálek> In reply to @leorize "type expression that uses": wdym by on return type? this doesn't work either: https://play.nim-lang.org/#ix=3LH5 |
20:45:22 | FromDiscord | <Michal Maršálek> What are the tricks |
20:47:24 | FromDiscord | <leorize> looks like your problem is different from mine |
20:48:14 | FromDiscord | <leorize> the trick is to create a typesection in the return value expression itself that aliases the generic type |
20:48:47 | FromDiscord | <leorize> that way any expressions using that will be deterred until the generic is instantiated |
20:49:07 | FromDiscord | <leorize> your problem seems to be in the template itself, though |
20:49:25 | FromDiscord | <Michal Maršálek> I don't really understand what you are saying |
20:49:29 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
20:56:02 | FromDiscord | <leorize> your problem right now is that the id template wants to be instantiated before T is available |
20:57:21 | FromDiscord | <Michal Maršálek> but `id` is not a generic? |
20:57:30 | FromDiscord | <leorize> it is a generic |
20:57:43 | FromDiscord | <leorize> typedesc is not a value type, it's a generic typeclass |
20:57:45 | FromDiscord | <Michal Maršálek> I thought it is just a regular compile time function |
20:57:55 | FromDiscord | <Michal Maršálek> which operates on types |
20:58:28 | FromDiscord | <leorize> that's not the case unfortunately |
20:58:40 | FromDiscord | <Michal Maršálek> i see |
21:00:05 | FromDiscord | <Michal Maršálek> than an untyped macro should work? |
21:00:26 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=3LHa |
21:00:42 | FromDiscord | <leorize> pretty terrible, but playing with typedesc is never pleasant in Nim |
21:01:36 | FromDiscord | <Michal Maršálek> Yeah I'm trying to understand the types, macros, and compile time stuff in general and I'm discovering some tricky things |
21:02:26 | FromDiscord | <Michal Maršálek> Why doesn't this macro work than? https://play.nim-lang.org/#ix=3LHf |
21:02:33 | FromDiscord | <Michal Maršálek> (edit) "than?" => "then?" |
21:03:34 | FromDiscord | <leorize> here's another fun fact about Nim... uninstantiated generics are not valid if not produced by sem |
21:04:00 | FromDiscord | <Michal Maršálek> what is sem, |
21:04:03 | FromDiscord | <Michal Maršálek> ? |
21:05:34 | FromDiscord | <leorize> sem is short for semantic analysis pass in the compiler |
21:06:16 | FromDiscord | <Michal Maršálek> In reply to @leorize "here's another fun fact": is this realted to why the macro doesn't work? |
21:09:33 | FromDiscord | <Michal Maršálek> ok, I can live without being able to call templates in the function signatures |
21:09:38 | FromDiscord | <Michal Maršálek> another question |
21:11:45 | FromDiscord | <leorize> yes, the T generated by your macro is considered to not exist |
21:13:26 | FromDiscord | <leorize> you can get template calling to work if you use that lousy workaround I outlined above |
21:13:52 | FromDiscord | <leorize> that's how my union macro deals with this stuff\: https://github.com/alaviss/union/blob/main/union.nim#L369 |
21:14:37 | FromDiscord | <leorize> https://github.com/alaviss/union/blob/main/union.nim#L338 |
21:15:55 | FromDiscord | <Michal Maršálek> In reply to @leorize "you can get template": ah thanks |
21:15:58 | FromDiscord | <Michal Maršálek> it works |
21:16:23 | FromDiscord | <Michal Maršálek> Ok another question: why is Nim complaining here? https://play.nim-lang.org/#ix=3LHm |
21:16:58 | FromDiscord | <leorize> welcome to the amazing world of typedesc |
21:17:27 | FromDiscord | <leorize> so... that T is a typedesc, meaning that it will become a `typedesc[T]` |
21:17:57 | FromDiscord | <leorize> you passed `int` to it, creating `typedesc[int]` as the type for your data field |
21:18:50 | FromDiscord | <0ffh> I've got some code I really need to speed up.↵It's a backtracking combinatorial solver, at it seems to spend >80% of it's time in genericDeepCopy of deepcopy.nim, which kind of makes sense.↵So what could I do to speed up the copying of my solver state object? |
21:19:27 | FromDiscord | <leorize> don't use deep copy |
21:19:58 | FromDiscord | <Michal Maršálek> @leorize that sounds complicated |
21:20:08 | FromDiscord | <leorize> assuming that you're storing your graph as a linked list-like object, you have to move it to an another representation |
21:20:28 | FromDiscord | <0ffh> K. The problem is, the state object has fields with tables and sequences.↵There's no linked lists. |
21:20:51 | FromDiscord | <leorize> does it have refs? |
21:20:54 | FromDiscord | <0ffh> I need those seqs and tables copied too. |
21:20:57 | FromDiscord | <0ffh> No refs. |
21:20:59 | FromDiscord | <leorize> it is↵(@Michal Maršálek) |
21:21:08 | FromDiscord | <leorize> @0ffh\: then just use normal copy |
21:21:26 | FromDiscord | <leorize> seqs and tables in Nim are value types |
21:21:36 | FromDiscord | <0ffh> In reply to @leorize "<@812269866366140427>\: then just use": Okay, that should be an easy experiment to do. |
21:22:43 | FromDiscord | <Michal Maršálek> In reply to @leorize "you passed `int` to": how do I write it correctly |
21:22:46 | FromDiscord | <Michal Maršálek> ? |
21:25:28 | FromDiscord | <leorize> that's the neat part, you don't |
21:25:40 | FromDiscord | <leorize> technically this is how it should be done\: https://play.nim-lang.org/#ix=3LHA |
21:25:58 | FromDiscord | <leorize> but it doesn't work, as usual for this kind of generics |
21:26:22 | FromDiscord | <Michal Maršálek> yeah |
21:26:30 | FromDiscord | <Michal Maršálek> that is what I had at first actually |
21:26:32 | FromDiscord | <leorize> small fix\: https://play.nim-lang.org/#ix=3LHB |
21:26:36 | FromDiscord | <leorize> still doesn't work |
21:27:13 | FromDiscord | <Michal Maršálek> I tried with the semicolon first ye |
21:29:03 | FromDiscord | <retkid> does anyone have a good up to date demo of arraymancer |
21:29:12 | FromDiscord | <retkid> currently it all looks like a pita |
21:29:31 | FromDiscord | <leorize> https://play.nim-lang.org/#ix=3LHF \<- "progress" |
21:30:05 | FromDiscord | <retkid> what are you doing an why |
21:30:06 | FromDiscord | <retkid> (edit) "an" => "and" |
21:30:36 | FromDiscord | <retkid> why |
21:30:40 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3LHG |
21:31:29 | FromDiscord | <retkid> the fact that you specify a..data nullifies any benefit from having the typecheck, and also its a typed function so why would you do that |
21:31:38 | FromDiscord | <retkid> (edit) "a..data" => "a.data" |
21:31:44 | FromDiscord | <leorize> playing gymnastics with the compiler to get @Michal Maršálek stuff to work lol |
21:32:04 | FromDiscord | <Michal Maršálek> I want to create a type which is generic in 1. a type T and 2. a value x:T |
21:32:09 | FromDiscord | <retkid> is Michal doing ``-gc:off`` nonsense |
21:32:17 | FromDiscord | <retkid> not literally that but in that vein |
21:32:33 | FromDiscord | <Elegantbeef> This is the type system it doesnt matter what memory management is doing |
21:32:45 | FromDiscord | <retkid> In reply to @retkid "not literally that but": wonder what that could mean |
21:33:33 | FromDiscord | <leorize> it's just generics crumbling on it's own weight |
21:33:38 | FromDiscord | <leorize> and typedesc doesn't help |
21:33:56 | FromDiscord | <retkid> its time to switch to an ML lang for this stuff |
21:34:07 | FromDiscord | <retkid> actually idk if that would help |
21:35:24 | FromDiscord | <Elegantbeef> What exactly are we after anyway? |
21:35:54 | FromDiscord | <leorize> somehow instantiate that type |
21:36:39 | FromDiscord | <Elegantbeef> It might not be possible simply cause i dont think Nim knows how to walk `[T; x: static T]` |
21:37:04 | FromDiscord | <Elegantbeef> Atleast in type def |
21:37:09 | FromDiscord | <leorize> yea I think so too |
21:37:27 | FromDiscord | <Elegantbeef> I could look at the culprit and see if it's simple |
21:37:37 | FromDiscord | <Elegantbeef> Though I doubt it's simple 😀 |
21:39:02 | FromDiscord | <retkid> see i wanna use arraymancer but i have no money to buy a training server and i have no gpu and an i5-4790 |
21:39:05 | FromDiscord | <retkid> (edit) "i5-4790" => "i5-4790S" |
21:39:16 | FromDiscord | <retkid> and im concerned that i will never actually train anything |
21:39:35 | FromDiscord | <leorize> your best bet for arraymancer guides is in the science channel |
21:40:43 | FromDiscord | <Isofruit> leorize, Elegantbeef, on the off chance, does one of you two have an idea on how to figure out within a nim program which package a given Exception-type comes from? |
21:40:57 | FromDiscord | <retkid> In reply to @leorize "your best bet for": its sad because I tried a bunch of different algorithms but i cant figure out any patterns in the data |
21:40:58 | FromDiscord | <Isofruit> (edit) "from?" => "from (at runtime)?" |
21:40:59 | FromDiscord | <0ffh> @leorize Haha, okay that dropped the time from 3:30 to 0:15! 🥳 😅 |
21:41:11 | FromDiscord | <Elegantbeef> you can use a macro |
21:41:13 | FromDiscord | <Elegantbeef> But it's runtime information so it doesnt overly help |
21:41:21 | FromDiscord | <0ffh> Thanks! |
21:41:43 | FromDiscord | <leorize> nice! |
21:41:59 | FromDiscord | <Elegantbeef> Is that hours or minutes? 😀 |
21:42:02 | FromDiscord | <Isofruit> Yeh, macro to get that info at compile time we (xflywind and I) contemplated but got kinda stuck there. |
21:42:07 | FromDiscord | <0ffh> 3min30sec to 15sec |
21:42:16 | FromDiscord | <leorize> @Isofruit\: you can if you reimplement RTTI in macros |
21:42:17 | FromDiscord | <Elegantbeef> What is your goal iso |
21:42:58 | FromDiscord | <leorize> nim doesn't have any idea about packages, mind you, you should be able to get module data but no more than that |
21:43:33 | FromDiscord | <Isofruit> API endpoints can throw all kinds of errors at runtime that I do not know ahead of time. When one occurs, I want to know a) which error type it is (that's easy enough, just log e.name) and b) what module needs to be imported to get access to that exception for a try-except statement |
21:43:38 | FromDiscord | <leorize> @0ffh\: deepCopy is pretty evil \:p |
21:44:07 | FromDiscord | <Elegantbeef> Well Nim knows what exceptions can be raised, so we can get the module name of them |
21:44:15 | FromDiscord | <Elegantbeef> This can be done all at CT for a block of code |
21:44:30 | FromDiscord | <retkid> In reply to @leorize "your best bet for": maybe best because im looking at this code and melting |
21:44:48 | FromDiscord | <retkid> who the fuck writes code like this ↵`` x.fc1.relu.fc2`` |
21:44:49 | FromDiscord | <leorize> `{.raises: [].}` and Nim will let you know what raises what |
21:45:14 | FromDiscord | <Isofruit> Yeh, ideally I'd be able to log that at runtime since the error itself may not occur at compile time / I may not be aware it occurs |
21:45:29 | FromDiscord | <retkid> In reply to @retkid "who the fuck writes": isn't one of the first things you learn in writing clean code is using descriptive variables. |
21:46:22 | * | Gustavo6046 quit (Remote host closed the connection) |
21:46:28 | FromDiscord | <leorize> everyone knows that you need short variable names so your program can access it faster, duh |
21:46:48 | FromDiscord | <retkid> oh ok its an optimization, not bad code |
21:46:53 | FromDiscord | <retkid> >:) |
21:46:54 | FromDiscord | <Elegantbeef> Leorize this isnt python or lua \:d |
21:47:23 | FromDiscord | <leorize> obligatory /s |
21:47:58 | FromDiscord | <Elegantbeef> Why do you need the /s here |
21:48:10 | FromDiscord | <Elegantbeef> It's compiled code if someone actually thinks that they have more issues than messy code 😀 |
21:48:35 | FromDiscord | <retkid> wat |
21:49:07 | FromDiscord | <retkid> the code has issues that i cant see because i cant understand it because the variables are named FOO AND VAR |
21:49:31 | FromDiscord | <Isofruit> Now back to seeing how constructor can make my life easier |
21:50:18 | FromDiscord | <Elegantbeef> Bet it wont↵(@Isofruit) |
21:50:36 | FromDiscord | <Isofruit> Have you already abandoned it? |
21:50:40 | * | Gustavo6046 joined #nim |
21:50:40 | FromDiscord | <leorize> that's the whole point of `{.raises: [].}`, to prevent any exception from being raised statically↵(@Isofruit) |
21:50:44 | FromDiscord | <Elegantbeef> Nah i recently made it better |
21:51:25 | FromDiscord | <SirOlaf> I am a back for more punishment related to that bug and think the compiler is wrong about comparing flags for generic types |
21:51:29 | FromDiscord | <Elegantbeef> Removed the dumb macros and now only going for `defaults` and `constr` |
21:52:20 | FromDiscord | <Isofruit> In reply to @leorize "that's the whole point": Isn't "raises" more a annotation (that is also verified) to show "hey, these exceptions cna be thrown by this function"? |
21:52:23 | FromDiscord | <retkid> i just learned if you hold alt you scroll faster in vscode |
21:53:21 | FromDiscord | <Isofruit> In reply to @Elegantbeef "Nah i recently made": Now I'm curious, why the assumption it won't make my life easier? |
21:53:22 | FromDiscord | <leorize> it's a constraint↵(@Isofruit) |
21:53:26 | FromDiscord | <0ffh> In reply to @leorize "<@812269866366140427>\: deepCopy is pretty": I'm surprised it makes such a great difference, I thought it only costs extra when there are actual references that need to be hunted down. 😆 ↵Anyways, that really dotted the is and crossed the ts on an already reasonable successful day for me.↵Also, you dropped this: :nim1: |
21:53:39 | FromDiscord | <Elegantbeef> and if you have a blank raises it means you cannot raise anything so have to handle it↵(@Isofruit) |
21:54:32 | FromDiscord | <Isofruit> Ohh you can force yourself to have to deal with all the exceptions at compile time and thus force the compiler to tell you of all the exceptions that are possible to occur? That... That is really neat |
21:54:38 | FromDiscord | <Isofruit> Does wonders for correctness |
21:57:01 | arkanoid | can you help me understand why vscode is not considering the .nim files in ~/.cache/nim/myproject_d/ ? I'm using futhark and it drops the generated nim files there. The code compiles but is hard and slow without the help of nimsuggest |
22:01:12 | FromDiscord | <Michal Maršálek> In reply to @Elegantbeef "It might not be": Would it somehow work without the requirement that x has type T? |
22:02:19 | FromDiscord | <Elegantbeef> Yea if you do `T; X: static int` i'd work |
22:02:34 | * | rp3 is now known as rlp10 |
22:02:34 | FromDiscord | <Michal Maršálek> I mean with a generic X: static |
22:03:06 | FromDiscord | <Michal Maršálek> ah thats nonsense |
22:03:25 | FromDiscord | <Michal Maršálek> nvm |
22:04:07 | FromDiscord | <leorize> it won't |
22:04:08 | FromDiscord | <Elegantbeef> `static` isnt a typeclass so indeed it'll not |
22:04:08 | FromDiscord | <leorize> but this is nim |
22:04:09 | FromDiscord | <leorize> I mean, it is a generic so technically it should be a typeclass |
22:04:58 | FromDiscord | <Michal Maršálek> I guess my only option is to make `X` a field and then use runtime asserts on it's value? |
22:05:16 | arkanoid | what's the most idiomatic way to translate a while with var assignment from C to nim? "while( (hFeature = OGR_L_GetNextFeature(hLayer)) != NULL ) { ... }" |
22:05:56 | FromDiscord | <Elegantbeef> `while (let hFeature = yourCall(hLayer); hFeature) != nil` |
22:06:18 | arkanoid | thanks! |
22:06:28 | FromDiscord | <leorize> the better way is to not do it because it's kind of a code smell \:p |
22:06:49 | FromDiscord | <Elegantbeef> Indeed |
22:06:51 | FromDiscord | <Michal Maršálek> (edit) "use runtime asserts" => "check it" | "it's value?" => "runtime?" |
22:07:42 | FromDiscord | <Michal Maršálek> well I'm trying to push myself as well as Nim and see what's possible |
22:07:43 | FromDiscord | <Isofruit> Ohhh defaults creates a `new<TypeName>` proc and a `<Type>.init()` proc |
22:07:59 | FromDiscord | <Elegantbeef> Does it do both? |
22:08:03 | FromDiscord | <Elegantbeef> Did i fuck something up? |
22:08:20 | FromDiscord | <Michal Maršálek> In reply to @leorize "the better way is": Not to do what? |
22:08:26 | FromDiscord | <Elegantbeef> If it does create both i fucked up |
22:08:35 | FromDiscord | <Elegantbeef> The while loop stuff michal |
22:08:48 | FromDiscord | <Isofruit> It appears to, I used to have `newCharacter` defined myself, I just commented it out |
22:09:10 | FromDiscord | <Elegantbeef> Well that's right, though i should add another parameter for it |
22:09:20 | FromDiscord | <Elegantbeef> One that allows the generic supporting `Character.new` |
22:09:40 | FromDiscord | <leorize> pretty much, though I'd prefer to avoid any kind of asserts↵(@Michal Maršálek) |
22:09:45 | FromDiscord | <Elegantbeef> For ref types it emits a `newT` for non-refs it emits `initT` |
22:09:50 | FromDiscord | <leorize> yea I was talking about the while loop thing↵(@Michal Maršálek) |
22:10:16 | FromDiscord | <Isofruit> works nicely with norm models and its tablename pragma |
22:10:49 | FromDiscord | <Elegantbeef> I will be making `implDefaults(Thingy, TypeDescConstr)` a thing when i get around to it |
22:10:58 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3LHT |
22:11:29 | FromDiscord | <Michal Maršálek> In reply to @leorize "pretty much, though I'd": That makes me very sad actually, but thank you all. 🙂 |
22:11:44 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3LHT" => "https://play.nim-lang.org/#ix=3LHV" |
22:11:46 | FromDiscord | <Elegantbeef> Yea that `Character.init` shouldnt work |
22:11:52 | FromDiscord | <Elegantbeef> So i guess bug found |
22:12:08 | FromDiscord | <Isofruit> Shall I open an issue so you don't have to? |
22:12:25 | FromDiscord | <Elegantbeef> Would be appreciated |
22:13:09 | * | PMunch quit (Quit: leaving) |
22:13:14 | FromDiscord | <Isofruit> Let me just first confirm that this is also an issue in inim, maybe the compiler just allows something illegal to happen that'll cause a runtime error |
22:13:36 | * | noeontheend joined #nim |
22:13:39 | FromDiscord | <Elegantbeef> I have a feeling it's the inheritance causing the issue |
22:19:02 | FromDiscord | <Isofruit> does nim by default provide a <Type>.new() proc? |
22:19:48 | arkanoid | leorize, sure, I first translate C -> nim 1:1, then I drop some more idiom in it |
22:19:49 | FromDiscord | <Isofruit> Huh, yeah it does |
22:19:58 | FromDiscord | <Isofruit> (edit) "does" => "does, if the Type is an object" |
22:20:00 | FromDiscord | <Recruit_main707> calling `new Type` will create a `ref Type` |
22:20:09 | FromDiscord | <Isofruit> Ahhh that explains it |
22:20:17 | NimEventer | New thread by Cantanima: What's the proper idiom?, see https://forum.nim-lang.org/t/8789 |
22:20:25 | FromDiscord | <Elegantbeef> It allocates a `ref Type` unless it's a ref type then it allocates just `Type` |
22:20:27 | FromDiscord | <Recruit_main707> its not exacty a <Type>.new() proc but it does the same |
22:20:55 | FromDiscord | <Isofruit> With the exception that it explodes in your face if you try to access any of its fields that store objects |
22:21:09 | FromDiscord | <Isofruit> or options |
22:21:20 | FromDiscord | <Isofruit> At least inim drowns me in a sea of red when I do that |
22:21:58 | FromDiscord | <Elegantbeef> `new T` will allocated only the root object so if you have other `ref T` it'll error↵(@Isofruit) |
22:24:35 | FromDiscord | <ajusa> I'm working on my html forms library and wanted to support multiselect, which means a sequence of strings. Right now a validator is defined as ` Validator = proc(value, label: string): string {.closure.}`. What's a good way to have a validator that'll operate on a sequence of strings? I've considered case objects but I feel like that may become too complicated. My honest reaction is to just treat sequences as a single deliminated string, |
22:25:21 | FromDiscord | <Isofruit> In reply to @Elegantbeef "`new T` will allocated": There is no bug, it merely compiled because I didn't call that function anywhere |
22:25:35 | FromDiscord | <Isofruit> (edit) "In reply to @Elegantbeef "`new T` will allocated": There is no bug, it merely compiled because I didn't call that function anywhere ... " added "and didn't realize" |
22:25:49 | FromDiscord | <Elegantbeef> but `init(Character)` isnt right |
22:26:51 | FromDiscord | <Isofruit> Kinda, it's more that the issue isn't noticed by the compiler if it is inside of dead code. `newModel(Character)`, which is the proc within which Character.init() is called, itself is never called anywhere ever |
22:27:12 | FromDiscord | <Isofruit> The second I do call it, the compiler implodes as it should |
22:31:20 | FromDiscord | <Isofruit> So false alarm, I apologize! |
22:32:35 | FromDiscord | <Elegantbeef> Oh cause it's a generic it's just an instantiation error |
22:38:52 | FromDiscord | <Elegantbeef> I found where the issue with the static is, no clue if it'll be a fun fix |
22:43:25 | FromDiscord | <deech> Is there a way to explicitly call the property of an object, eg. I'd like `obj.f` to always mean the `f` field of `obj` and error if it doesn't exist even if `proc f(obj:o ...)` exists. |
22:44:30 | FromDiscord | <deech> Even some kind of long hand is fine, like, `fieldOf(obj, f)` or something like that. |
22:45:49 | FromDiscord | <Elegantbeef> I could see term rewriting macros working here |
22:45:50 | FromDiscord | <Elegantbeef> Aside from that i dont know of a way |
22:46:50 | FromDiscord | <deech> I think it would be good to have some kind of builtin way of disambiguating. I try to stay away from term rewriting macros if possible. 🙂 |
22:47:26 | FromDiscord | <deech> Maybe something like `obj[f]`? |
22:47:58 | FromDiscord | <Elegantbeef> You could make that |
22:48:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LI6 |
22:48:47 | FromDiscord | <Elegantbeef> Doesnt prevent function calls though |
22:48:57 | FromDiscord | <Elegantbeef> Wrapping it could though |
22:50:11 | FromDiscord | <deech> Right, that's what I meant, I could write a macro that iterates over the field pairs and errors of `field` doesn't exist but in this case I think it would be good to have built in ways to disambiguate all uses of `.`. I run into issues all the time with module qualification as well. |
22:50:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LI7 |
22:50:37 | FromDiscord | <Elegantbeef> It's not too hard for this case |
22:51:10 | FromDiscord | <Elegantbeef> I've never had an issue with properties vs procedures so i'll keep hush |
22:51:24 | FromDiscord | <Elegantbeef> I mean fields vs procedures |
22:52:37 | FromDiscord | <Elegantbeef> So it was like 5 loc to fix the static issue! |
22:52:51 | FromDiscord | <Elegantbeef> Only took me an hour to two write |
22:53:06 | FromDiscord | <Elegantbeef> hour or two to write\ |
22:53:33 | FromDiscord | <evoalg> it's cos you got up too early beefy |
22:55:40 | FromDiscord | <Elegantbeef> Well i got too happy only fixed instantiation |
22:55:59 | FromDiscord | <Elegantbeef> dispatch is still borked |
22:56:46 | FromDiscord | <Elegantbeef> Wait nevermind, it works |
23:01:24 | FromDiscord | <treeform> In reply to @zetashift "<@107140179025735680>\: heyho, treeform, I'm": i have fixed the nimdocs now has right docs, some how it got stuck. |
23:01:59 | FromDiscord | <treeform> https://nimdocs.com/treeform/pixie/pixie.html |
23:05:13 | FromDiscord | <Isofruit> Managing to half the number of lines in my characterModel.nim thanks to constructor feels good |
23:05:38 | FromDiscord | <Isofruit> (edit) "half" => "halve" |
23:07:39 | FromDiscord | <Elegantbeef> Good to hear |
23:08:27 | FromDiscord | <Elegantbeef> Also worth noting you do not need the explicit types unless you really want to |
23:09:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LIc |
23:09:36 | FromDiscord | <deech> Oh wow, when did we get `{.defaults.}`? |
23:09:42 | FromDiscord | <Isofruit> Ah, you mean I can save myself the entire `name: string = ""` and just do name = "" |
23:09:43 | FromDiscord | <Elegantbeef> We didnt |
23:09:47 | FromDiscord | <Elegantbeef> My macro adds it |
23:09:58 | FromDiscord | <deech> Ah, cool! |
23:09:59 | FromDiscord | <Elegantbeef> https://github.com/beef331/constructor#defaults for context |
23:10:00 | FromDiscord | <Isofruit> That's fair, I just like to explicitly type my models |
23:12:06 | FromDiscord | <Elegantbeef> @SirOlaf\: any progress on your bug? |
23:12:50 | FromDiscord | <SirOlaf> Not really, I'm just confused that it's possible for the flags to be different after generateInstance |
23:12:54 | FromDiscord | <Isofruit> ... is there a lazy way to get nimble to update my projects nimble file for me? With all the packages I use and their versions etc? |
23:13:16 | FromDiscord | <Elegantbeef> It is not |
23:14:31 | FromDiscord | <SirOlaf> My phrasing was off, it's strange that the "template" in semBorrow can have different return type flags than the result of it |
23:14:40 | FromDiscord | <SirOlaf> And those flags must come from somewhere, and it should be generateInstance |
23:15:31 | FromDiscord | <Patitotective> In reply to @Elegantbeef "https://dev.to/beef331/demystification-of-macros-in": This was really helpful, Thanks 🙃 |
23:16:59 | FromDiscord | <SirOlaf> In reply to @SirOlaf "And those flags must": So either the flags are wrong or the comparison is too strict |
23:20:22 | FromDiscord | <tsoj> Is it possible to pass templates as function parameters? |
23:21:35 | FromDiscord | <Elegantbeef> No you can pass it to template/macros though |
23:22:38 | FromDiscord | <Elegantbeef> What're you trying to do? |
23:24:58 | * | justsomeguy joined #nim |
23:26:29 | FromDiscord | <tsoj> creating a function that converts instances of different types that have the same structure but different atomics at the lowest level (e.g. float instead of int), while also applying an operator when converting the atomics |
23:27:13 | FromDiscord | <Elegantbeef> Got an small example of the manual written code? |
23:27:41 | FromDiscord | <Elegantbeef> I think i understand but want to be certain before i suggest diving |
23:29:10 | FromDiscord | <tsoj> This works except for the custom operator: https://play.nim-lang.org/#ix=3LIh |
23:29:35 | * | crem quit (Ping timeout: 268 seconds) |
23:33:28 | FromDiscord | <retkid> what does |
23:33:33 | FromDiscord | <retkid> ``..<`` do |
23:33:45 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3LIi |
23:33:52 | FromDiscord | <Elegantbeef> depends on context |
23:34:03 | FromDiscord | <Elegantbeef> It's an iterator and also range construction |
23:34:24 | FromDiscord | <Elegantbeef> Tsoj that might work, you now can defined your own `converTo` procs for each field type which will be called on `a.convertTo` |
23:34:26 | FromDiscord | <retkid> its just a fancy way of doing x-1 |
23:34:42 | FromDiscord | <Elegantbeef> It's more readable yes |
23:34:51 | FromDiscord | <retkid> no its not |
23:34:58 | FromDiscord | <Elegantbeef> It is indeed |
23:35:39 | FromDiscord | <retkid> ``for a in 0 ..< 65`` is less readable then ``for a in 0 .. 65-1`` |
23:35:45 | FromDiscord | <retkid> (edit) "65-1``" => "65-1:``" |
23:35:51 | FromDiscord | <Elegantbeef> It's more readable |
23:35:58 | FromDiscord | <Elegantbeef> You know what's even more readable |
23:36:03 | FromDiscord | <Elegantbeef> `for a in 0..64` |
23:36:17 | FromDiscord | <retkid> well thats what the compiler sees |
23:36:31 | FromDiscord | <retkid> unfortunately humans are not compilers |
23:36:47 | FromDiscord | <Elegantbeef> But the point is `less than` is easy to comprehend to me atleast than `x -1` |
23:37:03 | FromDiscord | <Elegantbeef> Same semantics but the range operator is easier to understand |
23:37:21 | FromDiscord | <Elegantbeef> It reads left to right without any operations |
23:37:39 | FromDiscord | <retkid> i guess but then i gotta convert it into words in my brain so it takes more time |
23:38:05 | FromDiscord | <Elegantbeef> You dont convert it to words? |
23:38:07 | FromDiscord | <retkid> so its like↵"for all digits between x and y while x is less than why" |
23:38:10 | FromDiscord | <retkid> (edit) "why"" => "y"" |
23:38:32 | FromDiscord | <Elegantbeef> No it's more like `for x in range of 0 to less than y` |
23:38:36 | FromDiscord | <Elegantbeef> Atleast to me |
23:39:02 | FromDiscord | <Elegantbeef> Versus the mental overhead of reasoning the -1 and interpreting it |
23:39:05 | FromDiscord | <retkid> but i dont need to processes a loop when written like ``for a in x .. y`` |
23:39:06 | FromDiscord | <Elegantbeef> It's all subjective anywho |
23:39:10 | FromDiscord | <retkid> -1 |
23:39:18 | FromDiscord | <Elegantbeef> What ever you say |
23:39:30 | FromDiscord | <retkid> see, our brains work differently, and its pretty interesting |