<< 29-07-2021 >>

00:17:52*arkurious quit (Quit: Leaving)
00:36:46FromDiscord<Rika> I donโ€™t see how it is amazing
00:36:54FromDiscord<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:29fn<ForumUpdaterBot99> New thread by Phpostrich: NestedVM & Nim to make android apps?, see https://forum.nim-lang.org/t/8282
03:10:01FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> Anyone seen this error with postgresql on Mac OS? `Error: cannot 'importc' variable at compile time; pqsetdbLogin`
03:10:11FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> This is with nim installed from Homebrew
03:14:49FromDiscord<Elegantbeef> Are you trying to use `pqsetdblogin` in a static block or anywhere at compile time?
03:17:57FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> Nope I'm just calling `open` on db_postgres
03:18:28FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> `result.conn = db_postgres.open(uri, "", "", "")` that plus `import db_postgres` are the only things I'm using atm
03:20:49FromDiscord<Elegantbeef> `nim -v`?
03:20:51FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> 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:07FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> Nim Compiler Version 1.4.8 [MacOSX: arm64]
03:23:30FromDiscord<Elegantbeef> More code = more better
03:25:00FromDiscord<Elegantbeef> Not running mac, but those two lines work here so can only imagine you either left a detail out ๐Ÿ˜€
03:28:03FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> no problem, I just didn't want to paste the file if it was a stupid problem I missed ๐Ÿ™‚
03:28:23FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> sent a long message, see http://ix.io/3umJ
03:28:54FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> ` const db = newPgConnection("test", "test", "test")` is called from another file, but that's the extent of the calls
03:29:37FromDiscord<ElegantBeef> https://play.nim-lang.org/ saves eyeballs
03:30:16FromDiscord<Elegantbeef> Hey i asked if you were using it at compile time and you said no
03:30:40FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> https://play.nim-lang.org/#ix=3umL
03:30:40FromDiscord<Elegantbeef> `const` is compile time, change that to let and it wont error
03:31:03FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> ... ๐Ÿคฆ goddammit I'm sorry
03:31:14FromDiscord<๐“‘๐“ฎ๐“ท๐“พ๐“ถ๐“ซ๐“ฎ๐“ญ> I haven't written Nim in over a year and forgot const is compile time only
03:31:31FromDiscord<Elegantbeef> It's fine i dont blame you, well enough that it matters anyway
03:35:51FromDiscord<Rika> I blame beef
03:36:04FromDiscord<Elegantbeef> Indeed he's useless
03:46:57*ozzz quit (Quit: Bye)
03:47:17*ozzz joined #nim
03:49:09FromDiscord<generic linux user> what
03:55:22FromDiscord<Elegantbeef> Like said blame beef
03:56:16FromDiscord<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:03FromDiscord<generic linux user> that is really technical
04:33:59*rockcavera quit (Remote host closed the connection)
05:59:23FromDiscord<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:54FromDiscord<Elegantbeef> `astToStr`?
06:01:38FromDiscord<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:33FromDiscord<impbox [ftsf]> it's handy and i always forget it
07:26:48FromDiscord<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:31arkanoidI still kinda struggle to bend my daily nim programming into metaprogramming
08:34:53FromDiscord<haxscramper> you don't need to bend to metaprogramming
08:35:16FromDiscord<haxscramper> And honestly I'm writing a lot less macros now than I did earlier
08:35:21FromDiscord<haxscramper> s/writing/using in regular code/
09:09:25FromDiscord<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:21arkanoid:D
09:46:05mstmetaprogramming 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:55Mister_Magisterhow 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:25FromDiscord<impbox [ftsf]> try binding to it and see if it fails?
10:38:47Mister_Magisterthats what i thought
10:39:00Mister_Magisterbut its hard to deduce from docs
10:39:08Mister_Magisterasking for example is pretty shit but ugh
10:40:02*nixfreak_nim[m] joined #nim
10:40:16FromDiscord<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:38FromDiscord<impbox [ftsf]> EADDRINUSE
10:41:07FromDiscord<impbox [ftsf]> which network library are you using?
10:45:59Mister_Magisternone
10:46:04Mister_Magisteri jsut have empty nim file
10:46:42FromDiscord<impbox [ftsf]> well, easy way to test, bind to a port, then run your app twice
10:47:06FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/net.html
10:47:12Mister_Magisteri mean i have app running already
10:47:17Mister_Magisterjust want to check if its runing in nim
10:50:41FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3uo3
10:51:02FromDiscord<impbox [ftsf]> if you try to bind to the same port you'll get that exception
10:51:07FromDiscord<impbox [ftsf]> so you can detect that
10:52:36Mister_Magisteryeah i get that
10:52:40FromDiscord<enthus1ast> not always, (at least linux) also supports multiple processes bind to the same port, then it makes round robin
10:52:43Mister_Magisteri just don't get how to do that
10:52:44Mister_Magisterxd
10:54:31FromDiscord<generic linux user> guys , suppose i installed vlc on a windows pc, how will i call it from cmd using startprocess?
10:54:35FromDiscord<impbox [ftsf]> something like that maybe
10:54:38FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3uo5
10:54:42FromDiscord<generic linux user> (edit) "startprocess?" => "startprocess?โ†ตvlc or vlc.exe?"
10:54:57FromDiscord<generic linux user> (edit) "pc," => "pc by choco,"
10:54:59Mister_Magisteridk how to handle osError
10:55:17Mister_MagisterBut that handles all exceptions
10:55:20Mister_Magisternot just one
10:55:27FromDiscord<impbox [ftsf]> you can make it more specific if you like
10:55:31FromDiscord<enthus1ast> if on linux and (i think the first one) has used the sockopt SO\_REUSEPORT then this binding will succeed
10:55:31Mister_Magisterand i cant see any meaningful definition of osError
10:55:37Mister_Magisterin documentation its just int
10:55:52Mister_Magisterit doesn't have reuseport
10:56:13FromDiscord<enthus1ast> k
10:56:44Mister_Magisteri just idk how to handle osError
10:57:15Mister_Magisteryeah i just tried running it and the message says permission denied
10:57:23Mister_Magisterdoesn't look like port in use
10:57:38Mister_Magisteronly if i run it as root
10:57:47Mister_Magisterbut then again how do you handle osError
10:58:01Mister_MagisterOSErrorCode = distinct int32 its just int in docs
11:04:43*Vladar joined #nim
11:06:37FromDiscord<impbox [ftsf]> 10048 is the code for address in use
11:06:41FromDiscord<impbox [ftsf]> so you can check for that
11:06:54FromDiscord<impbox [ftsf]> though I suspect OSError is platform specific
11:07:02Mister_Magisterare there constants for os error codes?
11:07:23FromDiscord<impbox [ftsf]> probably not in nim since they're from the OS
11:07:28Mister_Magister98 is code i'm looking for
11:07:35FromDiscord<enthus1ast> you must be root to bind to ports lower than 1024โ†ต(<@709044657232936960_=4dister_=4dagister=5b=49=52=43=5d>)
11:08:09Mister_Magisteroh ye ye
11:09:22Mister_Magisterif i do except OSError: how do i get error code? getCurrentException() gets exception but its not of the type OSError
11:09:25FromDiscord<impbox [ftsf]> you can get the string with osErrorMsg
11:09:43FromDiscord<impbox [ftsf]> sent a code paste, see https://paste.rs/gW0
11:09:43Mister_Magisteri don't need string
11:09:48Mister_Magisteri want int
11:09:59FromDiscord<impbox [ftsf]> err.int
11:11:42Mister_Magisterhmm i want to compare OSErrorCode (which is int really) to number but it shows type mistmatch
11:12:33FromDiscord<impbox [ftsf]> if err.int == number:
11:12:54Mister_Magisterno, not that
11:13:09Mister_Magistercode == OSErrorCode(98) that works
11:13:24FromDiscord<impbox [ftsf]> yes you can do that too
11:13:39FromDiscord<impbox [ftsf]> you're converting 98 to OSErrorCode
11:13:42Mister_Magisteryes
11:13:48Mister_Magisterbecause nim cannot compare int to int
11:13:51FromDiscord<impbox [ftsf]> or converting an OSErrorCode to int is the same
11:13:55FromDiscord<impbox [ftsf]> nim can indeed compare int to int
11:14:02Mister_MagisterOSErrorCode is int
11:14:07FromDiscord<impbox [ftsf]> it's a distinct int
11:14:12Mister_Magisterwhats the diff
11:14:28FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/manual.html#types-distinct-type
11:16:11Mister_Magisterhuh
11:19:44FromDiscord<impbox [ftsf]> they don't compare to each other, unless you explicitly convert them
11:20:04FromDiscord<impbox [ftsf]> and distinct types don't use the operators from the base type
11:20:08FromDiscord<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:11fn<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:05FromDiscord<ynfle (ynfle)> You can covert to int by `int()`
14:07:14*rockcavera quit (Remote host closed the connection)
14:13:00arkanoidwhat'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:54FromDiscord<Rika> wdym?
14:13:55arkanoidI 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:11FromDiscord<Rika> if your lib and another dep share a dep (transient) then no cant be done i believe
14:15:21arkanoidok I'll keep using nix-shell. Not really the easiest solution
14:15:50arkanoidI'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:19arkanoidfor 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:59FromDiscord<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:46fn<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:51FromDiscord<haxscramper> In reply to @creonico "Hey, I have a": regular `items` returns immutable variables, just like `let`
16:00:12FromDiscord<haxscramper> You might want to use `mpairs` to take address of the elements
16:00:23FromDiscord<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:49FromDiscord<generic linux user> how to use case keyword for 2 variables
16:43:02FromDiscord<generic linux user> like:โ†ต of 'a' or 'A'
16:44:12FromDiscord<leorize> `of 'a', 'A'`
16:45:37FromDiscord<generic linux user> i seached evrywhere, i couldnt find โ€ข_โ€ข
16:45:43arkanoidwhat 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:10arkanoidI have to wrap nim programs with bash restart loops (actually docker restart loops)
16:52:35FromDiscord<Rika> `but your program will crash anyway`?
16:52:42FromDiscord<haxscramper> declaring main and wrapping it in the try-all does not work?
16:52:54FromDiscord<haxscramper> and not putting any executable code at toplevel
16:53:17arkanoidno, it crash anyway
16:53:30FromDiscord<haxscramper> by crash you mean?
16:53:33FromDiscord<haxscramper> exception or what
16:54:04FromDiscord<Rika> can you explain
16:54:06FromDiscord<haxscramper> and how language with mandatory `main()` is different for that
17:10:34FromDiscord<@bracketmaster-5a708063d73408ce4> beyond vlang and nim, are there other languages that bootstrap from c-sources?
17:13:41arkanoidalso 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:27fn<Prestige99> Which ones?
17:14:56fn<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:35arkanoidsomething 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:48fn<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:14FromDiscord<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:46FromDiscord<exelotl> But it sadly hasn't been maintained since 2015 or so
17:21:47FromDiscord<Rika> not to be confused with ookla xddd
17:22:27FromDiscord<exelotl> Ook! Ook. Ook? Ook.
17:22:43FromDiscord<@bracketmaster-5a708063d73408ce4> hmm...
17:22:48fn<Prestige99> @arkanoid file an issue, maybe. Sounds annoying
17:23:04FromDiscord<@bracketmaster-5a708063d73408ce4> why compile to C instead of LLVM? what are the design factors in such a decision
17:24:50FromDiscord<Rika> c interop
17:26:20*thunder joined #nim
17:28:22FromDiscord<@bracketmaster-5a708063d73408ce4> do you mean emitting C makes it easier to link against C libraries?
17:28:45arkanoidthis 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:01FromDiscord<haxscramper> Emitting C makes it easier to use C structures and libraries
17:29:16FromDiscord<haxscramper> It does not necessarily make it easier
17:29:31fn<Prestige99> @arkanoid was the issue not at gpsserver.nim(171) ?
17:29:31FromDiscord<leorize> llvm didn't exist
17:29:47FromDiscord<haxscramper> Also emitting C is less complex, 12 years ago LLVM was not a really an option from what I can undesrsta
17:29:47FromDiscord<haxscramper> ye
17:29:48FromDiscord<haxscramper> Also C++ interop
17:29:50arkanoidPrestige, that's the main
17:30:29arkanoidPrestice, it's the runForever()
17:30:56fn<Prestige99> can you show a minimal example and create an issue? would be good to clean up, if possible
17:33:12arkanoidnot 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:19arkanoid*now/not
17:34:48fn<Prestige99> Because of this one error? I wouldn't think it would be very difficult to find where it's happening
17:35:08FromDiscord<Rika> let me read it
17:35:48FromDiscord<Rika> eh it's just something in `uploadToTos`
17:36:21FromDiscord<Rika> arkanoid ^
17:39:01arkanoidthere's no list manipulation in that function, and what Exception message: index -3 not in 0 .. 5 does even mean
17:39:20arkanoidsorry I'm not angry just very nervous. I'm sorry
17:39:55FromDiscord<Rika> dont worry
17:39:57FromDiscord<Rika> its fine
17:40:06FromDiscord<Rika> this is a shitty error message yes
17:40:35FromDiscord<Rika> okay something you're `await`ing is fucking up, is what is likely
17:44:20arkanoidsure, thing, it's somewhere here, but that's really far far away from the indication of the traceback https://termbin.com/pcis
17:44:42arkanoidthe async trampoline is like 20 aways calls away in the tree
17:45:08FromDiscord<Rika> christ
17:46:02*Jjp137 quit (Ping timeout: 250 seconds)
17:48:01arkanoidso 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:44arkanoidI'd suggest: play stay away from async, it works until something dont and you are on your own
17:48:58FromDiscord<Rika> it should give the whole trace really
17:49:17FromDiscord<Rika> should have given
17:49:22arkanoidI'm using nim 1.4.8 stable
17:53:04FromDiscord<Rika> prolly something to do with d:release i assume? i do not know
17:53:06FromDiscord<Rika> i have to go
17:53:12FromDiscord<Rika> it is, like, 3am
17:55:56arkanoidno, that's a debug stacktrace
17:56:09arkanoidRika, thanks for the feedback. Much appreciated
18:05:04arkanoidwhat does "Exception message: index -3 not in 0 .. 5" mean?
18:06:34*SebastianM joined #nim
18:07:04fn<Prestige99> There's a range 0 to 5 - a number between 0 to 5 is expected, but -3 is provided
18:07:24fn<Prestige99> could be an array length 6 maybe
18:15:33*SebastianM quit (Ping timeout: 276 seconds)
18:17:29FromDiscord<dankrad> sent a code paste, see https://paste.rs/hRQ
18:18:22FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqb
18:18:27FromDiscord<haxscramper> you can error https://nim-lang.org/docs/macros.html#error%2Cstring%2CNimNode if pragma parameters are not valid
18:19:07FromDiscord<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:35FromDiscord<haxscramper> You can't really express this with types, at least when you place attributes for type declarations
18:19:43FromDiscord<dankrad> Means, I need to iterate over custom pragmas, to see if there's any other pragma which don't belong there?
18:19:49FromDiscord<dankrad> in a macro\
18:21:27FromDiscord<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:27FromDiscord<haxscramper> about doing this while you are in pragma itsef ...
18:23:19FromDiscord<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:47FromDiscord<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:51FromDiscord<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:19FromDiscord<haxscramper> I misunderstood the question at first - you only want to put for fields that are `object`?
18:24:33FromDiscord<dankrad> yep
18:25:03FromDiscord<haxscramper> So `{.Format: "".}: seq[int]` is incorrect
18:25:11FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqd
18:25:11FromDiscord<dankrad> this shouldn't be possible, because it's of type float
18:25:18FromDiscord<dankrad> exactly
18:25:43FromDiscord<haxscramper> Then you certainly need to accept `typed` argument as a pragma parameter, then `getTypeInst` to retrieve original type declaration
18:25:50FromDiscord<haxscramper> So something like
18:26:32FromDiscord<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:59FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqg
18:29:24FromDiscord<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:51FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqi
18:29:53FromDiscord<haxscramper> Formatted can itself be a macro pragma
18:30:07FromDiscord<haxscramper> You want to generate code based on that, or?
18:30:24FromDiscord<dankrad> I want to parse a string into an object in this case
18:30:38FromDiscord<dankrad> oops
18:30:46FromDiscord<dankrad> yeah I also want to generate code based on those pragmas
18:30:53FromDiscord<haxscramper> There are several solutions, but if you want to generate any additional code, or just record some data
18:31:33FromDiscord<haxscramper> okay, then you are -~~fucked~~-
18:31:40FromDiscord<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:51FromDiscord<haxscramper> So I did the same thing and it started with this
18:32:07FromDiscord<haxscramper> You can't generate code in the same type section, so you need to move it somewhere else
18:32:18FromDiscord<haxscramper> Specifically I made `genCode(TypeName)` that generated everything
18:32:43FromDiscord<haxscramper> sent a code paste, see https://paste.rs/qAk
18:33:11FromDiscord<haxscramper> `genCode` can have access to the original pragma implementation using typedesc as an argument, then `getTypeInst` on it
18:33:12FromDiscord<dankrad> Maybe I was incorrect or didn't get it correctly (language barier)
18:34:13FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqk
18:34:59FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3uqm
18:35:19FromDiscord<haxscramper> But you need to generate something that would parse things, right?
18:36:42FromDiscord<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:40FromDiscord<haxscramper> you can't do it with field annotation
18:37:48FromDiscord<haxscramper> you need either object-level annotation with `typed` argument
18:37:52FromDiscord<haxscramper> Or a separate macro call
18:39:40FromDiscord<haxscramper> And if you don't need to generate code at all, then you can just use object-level annotation
18:39:45FromDiscord<haxscramper> Though what is the point of the annotation in that case
18:40:05FromDiscord<haxscramper> Type-level annotation is this
18:47:44FromDiscord<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:12FromDiscord<dankrad> Sorry, I'm not that familiar with macros and pragmas. It's my first try.
18:51:01FromDiscord<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:30FromDiscord<dankrad> alright
18:52:14*SebastianM joined #nim
18:52:14FromDiscord<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:38FromDiscord<haxscramper> .
18:53:59FromDiscord<dankrad> And what's an object level annotation?
18:55:10FromDiscord<haxscramper> the same as object
18:55:12FromDiscord<haxscramper> object is a type
18:55:30FromDiscord<haxscramper> anyway, sorry if I confused you, I just mess up terms sometimes
18:55:56FromDiscord<haxscramper> But I mean `Object {.MyPragmaHere.} = object`
18:55:58FromDiscord<dankrad> ah, got it
18:56:01FromDiscord<dankrad> thank you
18:59:02FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqr
19:01:25*vicfred joined #nim
19:01:51FromDiscord<haxscramper> In reply to @haxscramper "https://wandbox.org/permlink/Q7ZIDj4rIs3l2YYB Is th": or maybe not
19:01:53FromDiscord<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:24FromDiscord<dankrad> \current
19:02:28FromDiscord<haxscramper> anyway, this is somewhat high-level macro, especially since you are in `typed` territory
19:08:24FromDiscord<haxscramper> yes
19:08:28FromDiscord<haxscramper> sent a code paste, see https://paste.rs/Jcd
19:08:58FromDiscord<haxscramper> Maybe there is another random combination of `getTypeInst()`, `getImpl()` that does what is necessary
19:10:45FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uqA
19:11:39FromDiscord<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:33FromDiscord<haxscramper> But you still need to call `FormatCheck(MyObj)` separately, because it seems you can't have `typed` pragma on object itself
19:13:43FromDiscord<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:10FromDiscord<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:45FromDiscord<carmysilna> in other words, is there a way to do `Rule[forall A. A]` in a Haskell-like syntax?
19:42:56FromDiscord<Elegantbeef> Is it an arbitrary variation of theses Rules?
19:45:04FromDiscord<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:31FromDiscord<carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3uqD
19:53:04FromDiscord<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:52FromDiscord<carmysilna> yeah, that might work, thaanks
20:18:55FromDiscord<carmysilna> (edit) "thaanks" => "thanks"
20:22:53FromDiscord<planetis> noob question, does the object construction syntax sets all the omitted fields to default values?
20:23:29FromDiscord<haxscramper> it sets values to zero-init memory
20:23:37FromDiscord<haxscramper> which is a default value
20:27:24FromDiscord<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:01FromDiscord<planetis> makes sense thats were the double zeromem is coming from
21:06:02FromDiscord<planetis> regardless this is the safest and in release its optimized away
21:07:08FromDiscord<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)