00:17:52 | * | arkurious quit (Quit: Leaving) |
00:36:46 | FromDiscord | <Rika> I donโt see how it is amazing |
00:36:54 | FromDiscord | <Rika> As Haskell is compiled as well |
01:04:13 | * | thunder quit (Killed (NickServ (GHOST command used by metasintactic))) |
01:04:14 | * | thunder joined #nim |
02:26:29 | fn | <ForumUpdaterBot99> New thread by Phpostrich: NestedVM & Nim to make android apps?, see https://forum.nim-lang.org/t/8282 |
03:10:01 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> Anyone seen this error with postgresql on Mac OS? `Error: cannot 'importc' variable at compile time; pqsetdbLogin` |
03:10:11 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> This is with nim installed from Homebrew |
03:14:49 | FromDiscord | <Elegantbeef> Are you trying to use `pqsetdblogin` in a static block or anywhere at compile time? |
03:17:57 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> Nope I'm just calling `open` on db_postgres |
03:18:28 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> `result.conn = db_postgres.open(uri, "", "", "")` that plus `import db_postgres` are the only things I'm using atm |
03:20:49 | FromDiscord | <Elegantbeef> `nim -v`? |
03:20:51 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> I've set the c include/lib paths too: `nim c --cincludes:/opt/homebrew/Cellar/postgresql/13.3/include --clib:lbpq --clibdir:/opt/homebrew/Cellar/postgresql/13.3/lib -d:ssl -r --outdir:build src/cryptotest.nim` |
03:21:07 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> Nim Compiler Version 1.4.8 [MacOSX: arm64] |
03:23:30 | FromDiscord | <Elegantbeef> More code = more better |
03:25:00 | FromDiscord | <Elegantbeef> Not running mac, but those two lines work here so can only imagine you either left a detail out ๐ |
03:28:03 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> no problem, I just didn't want to paste the file if it was a stupid problem I missed ๐ |
03:28:23 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> sent a long message, see http://ix.io/3umJ |
03:28:54 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> ` const db = newPgConnection("test", "test", "test")` is called from another file, but that's the extent of the calls |
03:29:37 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/ saves eyeballs |
03:30:16 | FromDiscord | <Elegantbeef> Hey i asked if you were using it at compile time and you said no |
03:30:40 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> https://play.nim-lang.org/#ix=3umL |
03:30:40 | FromDiscord | <Elegantbeef> `const` is compile time, change that to let and it wont error |
03:31:03 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> ... ๐คฆ goddammit I'm sorry |
03:31:14 | FromDiscord | <๐๐ฎ๐ท๐พ๐ถ๐ซ๐ฎ๐ญ> I haven't written Nim in over a year and forgot const is compile time only |
03:31:31 | FromDiscord | <Elegantbeef> It's fine i dont blame you, well enough that it matters anyway |
03:35:51 | FromDiscord | <Rika> I blame beef |
03:36:04 | FromDiscord | <Elegantbeef> Indeed he's useless |
03:46:57 | * | ozzz quit (Quit: Bye) |
03:47:17 | * | ozzz joined #nim |
03:49:09 | FromDiscord | <generic linux user> what |
03:55:22 | FromDiscord | <Elegantbeef> Like said blame beef |
03:56:16 | FromDiscord | <Elegantbeef> statistically speaking he causes more issues than he destroys |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:34 | * | supakeen joined #nim |
04:23:03 | FromDiscord | <generic linux user> that is really technical |
04:33:59 | * | rockcavera quit (Remote host closed the connection) |
05:59:23 | FromDiscord | <treeform> Does any one know if there is a way to convert a symbol into a string in a template? Some thing that can make this work: https://play.nim-lang.org/#ix=3un7 |
06:00:54 | FromDiscord | <Elegantbeef> `astToStr`? |
06:01:38 | FromDiscord | <treeform> astToStr is exactly what I was looking for, thanks! |
06:19:48 | * | [R] quit (Ping timeout: 258 seconds) |
06:35:31 | * | max22- joined #nim |
06:46:24 | * | max22- quit (Remote host closed the connection) |
06:47:13 | * | max22- joined #nim |
06:51:51 | * | vicfred quit (Quit: Leaving) |
07:25:08 | * | max22- quit (Ping timeout: 256 seconds) |
07:26:33 | FromDiscord | <impbox [ftsf]> it's handy and i always forget it |
07:26:48 | FromDiscord | <impbox [ftsf]> i can never remember the macro/template stuff |
07:31:32 | * | max22- joined #nim |
07:32:05 | * | neceve joined #nim |
08:03:51 | * | Vladar joined #nim |
08:07:42 | * | max22- quit (Remote host closed the connection) |
08:08:00 | * | max22- joined #nim |
08:28:16 | * | Mister_Magister quit (Excess Flood) |
08:28:36 | * | Mister_Magister joined #nim |
08:29:31 | arkanoid | I still kinda struggle to bend my daily nim programming into metaprogramming |
08:34:53 | FromDiscord | <haxscramper> you don't need to bend to metaprogramming |
08:35:16 | FromDiscord | <haxscramper> And honestly I'm writing a lot less macros now than I did earlier |
08:35:21 | FromDiscord | <haxscramper> s/writing/using in regular code/ |
09:09:25 | FromDiscord | <zidsal> who are you and what have you done with the real haxscramper |
09:29:36 | * | Vladar quit (Read error: Connection reset by peer) |
09:34:21 | arkanoid | :D |
09:46:05 | mst | metaprogramming is fun but it's very easy to overdo |
10:00:36 | * | xet7 quit (Remote host closed the connection) |
10:01:26 | * | xet7 joined #nim |
10:05:04 | * | [R] joined #nim |
10:13:55 | Mister_Magister | how can i check if port is in use? |
10:36:40 | * | nixfreak_nim[m] quit (Quit: Bridge terminating on SIGTERM) |
10:36:41 | * | happycorsair[m] quit (Quit: Bridge terminating on SIGTERM) |
10:36:41 | * | Helios quit (Quit: Bridge terminating on SIGTERM) |
10:38:25 | FromDiscord | <impbox [ftsf]> try binding to it and see if it fails? |
10:38:47 | Mister_Magister | thats what i thought |
10:39:00 | Mister_Magister | but its hard to deduce from docs |
10:39:08 | Mister_Magister | asking for example is pretty shit but ugh |
10:40:02 | * | nixfreak_nim[m] joined #nim |
10:40:16 | FromDiscord | <impbox [ftsf]> https://man7.org/linux/man-pages/man2/bind.2.html |
10:40:17 | * | Helios joined #nim |
10:40:31 | * | happycorsair[m] joined #nim |
10:40:38 | FromDiscord | <impbox [ftsf]> EADDRINUSE |
10:41:07 | FromDiscord | <impbox [ftsf]> which network library are you using? |
10:45:59 | Mister_Magister | none |
10:46:04 | Mister_Magister | i jsut have empty nim file |
10:46:42 | FromDiscord | <impbox [ftsf]> well, easy way to test, bind to a port, then run your app twice |
10:47:06 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/net.html |
10:47:12 | Mister_Magister | i mean i have app running already |
10:47:17 | Mister_Magister | just want to check if its runing in nim |
10:50:41 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3uo3 |
10:51:02 | FromDiscord | <impbox [ftsf]> if you try to bind to the same port you'll get that exception |
10:51:07 | FromDiscord | <impbox [ftsf]> so you can detect that |
10:52:36 | Mister_Magister | yeah i get that |
10:52:40 | FromDiscord | <enthus1ast> not always, (at least linux) also supports multiple processes bind to the same port, then it makes round robin |
10:52:43 | Mister_Magister | i just don't get how to do that |
10:52:44 | Mister_Magister | xd |
10:54:31 | FromDiscord | <generic linux user> guys , suppose i installed vlc on a windows pc, how will i call it from cmd using startprocess? |
10:54:35 | FromDiscord | <impbox [ftsf]> something like that maybe |
10:54:38 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3uo5 |
10:54:42 | FromDiscord | <generic linux user> (edit) "startprocess?" => "startprocess?โตvlc or vlc.exe?" |
10:54:57 | FromDiscord | <generic linux user> (edit) "pc," => "pc by choco," |
10:54:59 | Mister_Magister | idk how to handle osError |
10:55:17 | Mister_Magister | But that handles all exceptions |
10:55:20 | Mister_Magister | not just one |
10:55:27 | FromDiscord | <impbox [ftsf]> you can make it more specific if you like |
10:55:31 | FromDiscord | <enthus1ast> if on linux and (i think the first one) has used the sockopt SO\_REUSEPORT then this binding will succeed |
10:55:31 | Mister_Magister | and i cant see any meaningful definition of osError |
10:55:37 | Mister_Magister | in documentation its just int |
10:55:52 | Mister_Magister | it doesn't have reuseport |
10:56:13 | FromDiscord | <enthus1ast> k |
10:56:44 | Mister_Magister | i just idk how to handle osError |
10:57:15 | Mister_Magister | yeah i just tried running it and the message says permission denied |
10:57:23 | Mister_Magister | doesn't look like port in use |
10:57:38 | Mister_Magister | only if i run it as root |
10:57:47 | Mister_Magister | but then again how do you handle osError |
10:58:01 | Mister_Magister | OSErrorCode = distinct int32 its just int in docs |
11:04:43 | * | Vladar joined #nim |
11:06:37 | FromDiscord | <impbox [ftsf]> 10048 is the code for address in use |
11:06:41 | FromDiscord | <impbox [ftsf]> so you can check for that |
11:06:54 | FromDiscord | <impbox [ftsf]> though I suspect OSError is platform specific |
11:07:02 | Mister_Magister | are there constants for os error codes? |
11:07:23 | FromDiscord | <impbox [ftsf]> probably not in nim since they're from the OS |
11:07:28 | Mister_Magister | 98 is code i'm looking for |
11:07:35 | FromDiscord | <enthus1ast> you must be root to bind to ports lower than 1024โต(<@709044657232936960_=4dister_=4dagister=5b=49=52=43=5d>) |
11:08:09 | Mister_Magister | oh ye ye |
11:09:22 | Mister_Magister | if i do except OSError: how do i get error code? getCurrentException() gets exception but its not of the type OSError |
11:09:25 | FromDiscord | <impbox [ftsf]> you can get the string with osErrorMsg |
11:09:43 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://paste.rs/gW0 |
11:09:43 | Mister_Magister | i don't need string |
11:09:48 | Mister_Magister | i want int |
11:09:59 | FromDiscord | <impbox [ftsf]> err.int |
11:11:42 | Mister_Magister | hmm i want to compare OSErrorCode (which is int really) to number but it shows type mistmatch |
11:12:33 | FromDiscord | <impbox [ftsf]> if err.int == number: |
11:12:54 | Mister_Magister | no, not that |
11:13:09 | Mister_Magister | code == OSErrorCode(98) that works |
11:13:24 | FromDiscord | <impbox [ftsf]> yes you can do that too |
11:13:39 | FromDiscord | <impbox [ftsf]> you're converting 98 to OSErrorCode |
11:13:42 | Mister_Magister | yes |
11:13:48 | Mister_Magister | because nim cannot compare int to int |
11:13:51 | FromDiscord | <impbox [ftsf]> or converting an OSErrorCode to int is the same |
11:13:55 | FromDiscord | <impbox [ftsf]> nim can indeed compare int to int |
11:14:02 | Mister_Magister | OSErrorCode is int |
11:14:07 | FromDiscord | <impbox [ftsf]> it's a distinct int |
11:14:12 | Mister_Magister | whats the diff |
11:14:28 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/manual.html#types-distinct-type |
11:16:11 | Mister_Magister | huh |
11:19:44 | FromDiscord | <impbox [ftsf]> they don't compare to each other, unless you explicitly convert them |
11:20:04 | FromDiscord | <impbox [ftsf]> and distinct types don't use the operators from the base type |
11:20:08 | FromDiscord | <impbox [ftsf]> unless they borrow them |
11:58:18 | * | Mister_Magister quit (Remote host closed the connection) |
11:58:37 | * | Mister_Magister joined #nim |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:35 | * | supakeen joined #nim |
12:43:20 | * | rockcavera joined #nim |
12:43:20 | * | rockcavera quit (Changing host) |
12:43:20 | * | rockcavera joined #nim |
12:52:07 | * | Vladar quit (Remote host closed the connection) |
12:54:14 | * | Vladar joined #nim |
13:08:11 | fn | <ForumUpdaterBot99> New question by bumbread: Nim infinite loop, see https://stackoverflow.com/questions/68464490/nim-infinite-loop |
13:22:58 | * | max22- quit (Ping timeout: 240 seconds) |
13:54:08 | * | beshr quit (Remote host closed the connection) |
14:00:52 | * | beshr joined #nim |
14:04:05 | FromDiscord | <ynfle (ynfle)> You can covert to int by `int()` |
14:07:14 | * | rockcavera quit (Remote host closed the connection) |
14:13:00 | arkanoid | what's the best way to use nimble properly to fix dependency versions and enforcing them in such a way that other project are free to use whatever other version the need? |
14:13:54 | FromDiscord | <Rika> wdym? |
14:13:55 | arkanoid | I still have enverything in ~/.nimble, and I've moved stuff where I do need reproducibility in a nix-shell, so I've a grey area in the middle |
14:14:11 | FromDiscord | <Rika> if your lib and another dep share a dep (transient) then no cant be done i believe |
14:15:21 | arkanoid | ok I'll keep using nix-shell. Not really the easiest solution |
14:15:50 | arkanoid | I'd be much more happy if .nimble would handle a local folder in project with enforced dependency versions according to nimble file |
14:22:42 | * | Vladar quit (Quit: Leaving) |
14:24:19 | arkanoid | for a new io bound project, would you go threadpool, async, or something else? |
14:41:51 | * | max22- joined #nim |
14:43:22 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
14:59:51 | * | neceve quit (Ping timeout: 268 seconds) |
15:44:59 | FromDiscord | <creonico> Hey, I have a for loop that uses `pairs()` to iterate over a sequence, `for i, content in contents.pairs():`. But when I give the address of the item returned by pairs(), `content.addr` to a pointer of that type. I get `expression has no address; maybe use 'unsafeAddr'` why? |
15:56:46 | fn | <ForumUpdaterBot99> New thread by Veksha: [0..min(10,^1)], see https://forum.nim-lang.org/t/8283 |
15:58:58 | * | arkurious joined #nim |
15:59:51 | FromDiscord | <haxscramper> In reply to @creonico "Hey, I have a": regular `items` returns immutable variables, just like `let` |
16:00:12 | FromDiscord | <haxscramper> You might want to use `mpairs` to take address of the elements |
16:00:23 | FromDiscord | <haxscramper> `for i, content in mpairs(contents):` |
16:14:48 | * | neceve joined #nim |
16:32:03 | * | max22- quit (Remote host closed the connection) |
16:38:50 | * | max22- joined #nim |
16:42:49 | FromDiscord | <generic linux user> how to use case keyword for 2 variables |
16:43:02 | FromDiscord | <generic linux user> like:โต of 'a' or 'A' |
16:44:12 | FromDiscord | <leorize> `of 'a', 'A'` |
16:45:37 | FromDiscord | <generic linux user> i seached evrywhere, i couldnt find โข_โข |
16:45:43 | arkanoid | what makes me want to switch to another language is the impossibility to handle errors properly. You can wrap you main with a catch-all exception block, but your program will crash anyway |
16:46:10 | arkanoid | I have to wrap nim programs with bash restart loops (actually docker restart loops) |
16:52:35 | FromDiscord | <Rika> `but your program will crash anyway`? |
16:52:42 | FromDiscord | <haxscramper> declaring main and wrapping it in the try-all does not work? |
16:52:54 | FromDiscord | <haxscramper> and not putting any executable code at toplevel |
16:53:17 | arkanoid | no, it crash anyway |
16:53:30 | FromDiscord | <haxscramper> by crash you mean? |
16:53:33 | FromDiscord | <haxscramper> exception or what |
16:54:04 | FromDiscord | <Rika> can you explain |
16:54:06 | FromDiscord | <haxscramper> and how language with mandatory `main()` is different for that |
17:10:34 | FromDiscord | <@bracketmaster-5a708063d73408ce4> beyond vlang and nim, are there other languages that bootstrap from c-sources? |
17:13:41 | arkanoid | also the error messages with async are terrible |
17:13:53 | * | rockcavera joined #nim |
17:13:53 | * | rockcavera quit (Changing host) |
17:13:53 | * | rockcavera joined #nim |
17:14:27 | fn | <Prestige99> Which ones? |
17:14:56 | fn | <ForumUpdaterBot99> New thread by Alexeypetrushin: Data Notebook in Nim | PL0T, see https://forum.nim-lang.org/t/8284 |
17:15:06 | * | thunder quit (Ping timeout: 240 seconds) |
17:16:35 | arkanoid | something like: Async traceback: Exception message: index -3 not in 0 .. 5 and the nearest point in my source to traceback the error is ... main trampoline |
17:17:48 | fn | <ForumUpdaterBot99> New post on r/nim by h234sd: Data Notebook in Nim | PL0T, see https://reddit.com/r/nim/comments/ou1su3/data_notebook_in_nim_pl0t/ |
17:21:14 | FromDiscord | <exelotl> In reply to @@bracketmaster-5a708063d73408ce4 "beyond vlang and nim,": I came from ooc-lang which also did the whole 'sexy modern language that compiles to C' thing |
17:21:46 | FromDiscord | <exelotl> But it sadly hasn't been maintained since 2015 or so |
17:21:47 | FromDiscord | <Rika> not to be confused with ookla xddd |
17:22:27 | FromDiscord | <exelotl> Ook! Ook. Ook? Ook. |
17:22:43 | FromDiscord | <@bracketmaster-5a708063d73408ce4> hmm... |
17:22:48 | fn | <Prestige99> @arkanoid file an issue, maybe. Sounds annoying |
17:23:04 | FromDiscord | <@bracketmaster-5a708063d73408ce4> why compile to C instead of LLVM? what are the design factors in such a decision |
17:24:50 | FromDiscord | <Rika> c interop |
17:26:20 | * | thunder joined #nim |
17:28:22 | FromDiscord | <@bracketmaster-5a708063d73408ce4> do you mean emitting C makes it easier to link against C libraries? |
17:28:45 | arkanoid | this is the kind of traceback you get when you do the wise choice to pick nim async/await. I wish I started with thread instead https://termbin.com/oum9 |
17:29:01 | FromDiscord | <haxscramper> Emitting C makes it easier to use C structures and libraries |
17:29:16 | FromDiscord | <haxscramper> It does not necessarily make it easier |
17:29:31 | fn | <Prestige99> @arkanoid was the issue not at gpsserver.nim(171) ? |
17:29:31 | FromDiscord | <leorize> llvm didn't exist |
17:29:47 | FromDiscord | <haxscramper> Also emitting C is less complex, 12 years ago LLVM was not a really an option from what I can undesrsta |
17:29:47 | FromDiscord | <haxscramper> ye |
17:29:48 | FromDiscord | <haxscramper> Also C++ interop |
17:29:50 | arkanoid | Prestige, that's the main |
17:30:29 | arkanoid | Prestice, it's the runForever() |
17:30:56 | fn | <Prestige99> can you show a minimal example and create an issue? would be good to clean up, if possible |
17:33:12 | arkanoid | not sure I want to do so. I'm failing to fix a bug in production due to this, I will probably have to kick nim outside production due to this and I'm now happy |
17:33:19 | arkanoid | *now/not |
17:34:48 | fn | <Prestige99> Because of this one error? I wouldn't think it would be very difficult to find where it's happening |
17:35:08 | FromDiscord | <Rika> let me read it |
17:35:48 | FromDiscord | <Rika> eh it's just something in `uploadToTos` |
17:36:21 | FromDiscord | <Rika> arkanoid ^ |
17:39:01 | arkanoid | there's no list manipulation in that function, and what Exception message: index -3 not in 0 .. 5 does even mean |
17:39:20 | arkanoid | sorry I'm not angry just very nervous. I'm sorry |
17:39:55 | FromDiscord | <Rika> dont worry |
17:39:57 | FromDiscord | <Rika> its fine |
17:40:06 | FromDiscord | <Rika> this is a shitty error message yes |
17:40:35 | FromDiscord | <Rika> okay something you're `await`ing is fucking up, is what is likely |
17:44:20 | arkanoid | sure, thing, it's somewhere here, but that's really far far away from the indication of the traceback https://termbin.com/pcis |
17:44:42 | arkanoid | the async trampoline is like 20 aways calls away in the tree |
17:45:08 | FromDiscord | <Rika> christ |
17:46:02 | * | Jjp137 quit (Ping timeout: 250 seconds) |
17:48:01 | arkanoid | so what you get in error while working with async: where the trampoline is (hell yeah I know) and a partial mangled mane of the last {.async.} called. Then you're in the dark no matter how deep the call tree is within that last async |
17:48:44 | arkanoid | I'd suggest: play stay away from async, it works until something dont and you are on your own |
17:48:58 | FromDiscord | <Rika> it should give the whole trace really |
17:49:17 | FromDiscord | <Rika> should have given |
17:49:22 | arkanoid | I'm using nim 1.4.8 stable |
17:53:04 | FromDiscord | <Rika> prolly something to do with d:release i assume? i do not know |
17:53:06 | FromDiscord | <Rika> i have to go |
17:53:12 | FromDiscord | <Rika> it is, like, 3am |
17:55:56 | arkanoid | no, that's a debug stacktrace |
17:56:09 | arkanoid | Rika, thanks for the feedback. Much appreciated |
18:05:04 | arkanoid | what does "Exception message: index -3 not in 0 .. 5" mean? |
18:06:34 | * | SebastianM joined #nim |
18:07:04 | fn | <Prestige99> There's a range 0 to 5 - a number between 0 to 5 is expected, but -3 is provided |
18:07:24 | fn | <Prestige99> could be an array length 6 maybe |
18:15:33 | * | SebastianM quit (Ping timeout: 276 seconds) |
18:17:29 | FromDiscord | <dankrad> sent a code paste, see https://paste.rs/hRQ |
18:18:22 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqb |
18:18:27 | FromDiscord | <haxscramper> you can error https://nim-lang.org/docs/macros.html#error%2Cstring%2CNimNode if pragma parameters are not valid |
18:19:07 | FromDiscord | <haxscramper> `> This macro should only be used on attributes with object as base type.` you need to check whether ast passed to pragma is correct or not |
18:19:35 | FromDiscord | <haxscramper> You can't really express this with types, at least when you place attributes for type declarations |
18:19:43 | FromDiscord | <dankrad> Means, I need to iterate over custom pragmas, to see if there's any other pragma which don't belong there? |
18:19:49 | FromDiscord | <dankrad> in a macro\ |
18:21:27 | FromDiscord | <haxscramper> `> is there a macro (I didn't see) to iterate over custom pragmas?` get type inst returns structure of the object as declared in code with all pragma parameters https://nim-lang.org/docs/macros.html#getTypeInst%2CNimNode |
18:21:27 | FromDiscord | <haxscramper> about doing this while you are in pragma itsef ... |
18:23:19 | FromDiscord | <haxscramper> I suppose this is doable, but you probably would need to accept `typed` argument for a pragma, then get back to the typeInst |
18:23:47 | FromDiscord | <dankrad> Well, currently I'm using templates as custom pragma. This means I should create a macro which is aborting compilation with getTypeInst? |
18:23:51 | FromDiscord | <haxscramper> `> I want to prevent to put macros to attributes with other types and abort compilation.` - it would probably solve this as well |
18:24:19 | FromDiscord | <haxscramper> I misunderstood the question at first - you only want to put for fields that are `object`? |
18:24:33 | FromDiscord | <dankrad> yep |
18:25:03 | FromDiscord | <haxscramper> So `{.Format: "".}: seq[int]` is incorrect |
18:25:11 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqd |
18:25:11 | FromDiscord | <dankrad> this shouldn't be possible, because it's of type float |
18:25:18 | FromDiscord | <dankrad> exactly |
18:25:43 | FromDiscord | <haxscramper> Then you certainly need to accept `typed` argument as a pragma parameter, then `getTypeInst` to retrieve original type declaration |
18:25:50 | FromDiscord | <haxscramper> So something like |
18:26:32 | FromDiscord | <dankrad> but this then doesn't work with custom pragmas declared with templates I assume. Then i need to create the custom pragma with a macro, right? |
18:26:59 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqg |
18:29:24 | FromDiscord | <haxscramper> If I remember correctly you can't just use macros as custom pragma, so you need to get a little more involved setup for thsi |
18:29:51 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqi |
18:29:53 | FromDiscord | <haxscramper> Formatted can itself be a macro pragma |
18:30:07 | FromDiscord | <haxscramper> You want to generate code based on that, or? |
18:30:24 | FromDiscord | <dankrad> I want to parse a string into an object in this case |
18:30:38 | FromDiscord | <dankrad> oops |
18:30:46 | FromDiscord | <dankrad> yeah I also want to generate code based on those pragmas |
18:30:53 | FromDiscord | <haxscramper> There are several solutions, but if you want to generate any additional code, or just record some data |
18:31:33 | FromDiscord | <haxscramper> okay, then you are -~~fucked~~- |
18:31:40 | FromDiscord | <haxscramper> 1. Accept `typed` parameter for pragmaโต2. Collect all fields in the flag list. Name+typeโต3. `getTypeInst` to get the original `{.Format` pragma |
18:31:51 | FromDiscord | <haxscramper> So I did the same thing and it started with this |
18:32:07 | FromDiscord | <haxscramper> You can't generate code in the same type section, so you need to move it somewhere else |
18:32:18 | FromDiscord | <haxscramper> Specifically I made `genCode(TypeName)` that generated everything |
18:32:43 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/qAk |
18:33:11 | FromDiscord | <haxscramper> `genCode` can have access to the original pragma implementation using typedesc as an argument, then `getTypeInst` on it |
18:33:12 | FromDiscord | <dankrad> Maybe I was incorrect or didn't get it correctly (language barier) |
18:34:13 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqk |
18:34:59 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqm |
18:35:19 | FromDiscord | <haxscramper> But you need to generate something that would parse things, right? |
18:36:42 | FromDiscord | <dankrad> I don't get it. The parser to parse into object's is already written. Currently I just want to define that this pragma isn't allowed on any other type then object. |
18:37:40 | FromDiscord | <haxscramper> you can't do it with field annotation |
18:37:48 | FromDiscord | <haxscramper> you need either object-level annotation with `typed` argument |
18:37:52 | FromDiscord | <haxscramper> Or a separate macro call |
18:39:40 | FromDiscord | <haxscramper> And if you don't need to generate code at all, then you can just use object-level annotation |
18:39:45 | FromDiscord | <haxscramper> Though what is the point of the annotation in that case |
18:40:05 | FromDiscord | <haxscramper> Type-level annotation is this |
18:47:44 | FromDiscord | <dankrad> But then I need to iterate over pragmas with a macro and check if there's a macro set which I don't want. Right? |
18:48:12 | FromDiscord | <dankrad> Sorry, I'm not that familiar with macros and pragmas. It's my first try. |
18:51:01 | FromDiscord | <haxscramper> yes, that is correct. Recursively iterate over `getTypeInst()` in order to get list of fields that were annotated, then recurse again, but now on `getTypeImpl()` (which returns typed body), and check whether any of the fields were wrongly annotated |
18:51:30 | FromDiscord | <dankrad> alright |
18:52:14 | * | SebastianM joined #nim |
18:52:14 | FromDiscord | <dankrad> could you be also so kind and give me an example of an object-level annotation? I don't know the difference between type and object level annotation. |
18:52:38 | FromDiscord | <haxscramper> . |
18:53:59 | FromDiscord | <dankrad> And what's an object level annotation? |
18:55:10 | FromDiscord | <haxscramper> the same as object |
18:55:12 | FromDiscord | <haxscramper> object is a type |
18:55:30 | FromDiscord | <haxscramper> anyway, sorry if I confused you, I just mess up terms sometimes |
18:55:56 | FromDiscord | <haxscramper> But I mean `Object {.MyPragmaHere.} = object` |
18:55:58 | FromDiscord | <dankrad> ah, got it |
18:56:01 | FromDiscord | <dankrad> thank you |
18:59:02 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqr |
19:01:25 | * | vicfred joined #nim |
19:01:51 | FromDiscord | <haxscramper> In reply to @haxscramper "https://wandbox.org/permlink/Q7ZIDj4rIs3l2YYB Is th": or maybe not |
19:01:53 | FromDiscord | <dankrad> ah, ok. Now I really got what you wanted to tell me. I'll play around with this approach. But it looks more cleaner then my approach. |
19:02:24 | FromDiscord | <dankrad> \current |
19:02:28 | FromDiscord | <haxscramper> anyway, this is somewhat high-level macro, especially since you are in `typed` territory |
19:08:24 | FromDiscord | <haxscramper> yes |
19:08:28 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/Jcd |
19:08:58 | FromDiscord | <haxscramper> Maybe there is another random combination of `getTypeInst()`, `getImpl()` that does what is necessary |
19:10:45 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqA |
19:11:39 | FromDiscord | <haxscramper> I forgot `getImpl()` returns semchecked AST as well, so you just need to traverse it, for each `nnkIdentDefs` you find, check if it has pragma in the fist argument |
19:13:33 | FromDiscord | <haxscramper> But you still need to call `FormatCheck(MyObj)` separately, because it seems you can't have `typed` pragma on object itself |
19:13:43 | FromDiscord | <haxscramper> I hope I'm wrong with this one, and there is a way to do this |
19:25:30 | * | supakeen quit (Remote host closed the connection) |
19:25:54 | * | supakeen joined #nim |
19:39:10 | FromDiscord | <carmysilna> If I have a type `Rule[A]` and I want a `const` `seq[Rule[_]]` where I can have different types of `Rule`s in the `seq`, but the Rule object has internal generics that need to be consistent with each other |
19:42:45 | FromDiscord | <carmysilna> in other words, is there a way to do `Rule[forall A. A]` in a Haskell-like syntax? |
19:42:56 | FromDiscord | <Elegantbeef> Is it an arbitrary variation of theses Rules? |
19:45:04 | FromDiscord | <Elegantbeef> The way to do this in nim is to manually box all variations in an object variant, which for arbitrary values is quite tedious |
19:45:19 | * | Jjp137 joined #nim |
19:46:20 | * | vicfred quit (Ping timeout: 258 seconds) |
19:48:31 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3uqD |
19:53:04 | FromDiscord | <Elegantbeef> Yea like i said a variant would work here, be it a safe one or an unsafe one(done lazily using an int and a macro table to do the unpacking where needed) https://play.nim-lang.org/#ix=3uqE |
20:00:29 | * | SebastianM quit (Quit: Bye) |
20:18:52 | FromDiscord | <carmysilna> yeah, that might work, thaanks |
20:18:55 | FromDiscord | <carmysilna> (edit) "thaanks" => "thanks" |
20:22:53 | FromDiscord | <planetis> noob question, does the object construction syntax sets all the omitted fields to default values? |
20:23:29 | FromDiscord | <haxscramper> it sets values to zero-init memory |
20:23:37 | FromDiscord | <haxscramper> which is a default value |
20:27:24 | FromDiscord | <planetis> ok ty |
20:50:27 | * | vicfred joined #nim |
20:56:28 | * | max22- quit (Remote host closed the connection) |
20:56:51 | * | max22- joined #nim |
21:06:01 | FromDiscord | <planetis> makes sense thats were the double zeromem is coming from |
21:06:02 | FromDiscord | <planetis> regardless this is the safest and in release its optimized away |
21:07:08 | FromDiscord | <planetis> (at least for clang) |
21:15:54 | * | Mister_Magister quit (Quit: bye) |
21:17:38 | * | Mister_Magister joined #nim |
21:21:22 | * | neceve quit (Ping timeout: 245 seconds) |
23:02:02 | * | max22- quit (Remote host closed the connection) |
23:56:43 | * | vicfred_ joined #nim |
23:59:08 | * | vicfred quit (Ping timeout: 250 seconds) |