<< 09-02-2022 >>

00:07:50*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
00:12:29FromDiscord<Waldecir Santos> Yeah I don't think it's possible rightnow, but maybe I can mimic procvar and that could work, I'll try tomorrow, thank you for helping @ElegantBeef
00:34:27*vicecea quit (Read error: Connection reset by peer)
00:34:41*vicfred quit (Quit: Leaving)
00:34:52*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
00:34:57*vicecea joined #nim
00:49:09*lumo_e quit (Quit: Quit)
00:51:53*ehmry joined #nim
02:11:29*neurocyte0917090 quit (Ping timeout: 256 seconds)
02:19:26*arkurious quit (Quit: Leaving)
02:59:10FromDiscord<michaelb> sent a long message, see http://ix.io/3P5X
02:59:50FromDiscord<michaelb> (edit) "http://ix.io/3P5X" => "https://paste.rs/xrk"
03:00:35FromDiscord<michaelb> I was looking at the blog post re: the announcement for Nim v1.2, but nothing jumped out at me yet, though I may have missed something
03:00:55FromDiscord<michaelb> (edit) "sent" => "was there something that changed between Nim v1.0 and v1.2 re: order of proc declaration/definition?↵↵with Nim v1.2.x, I'm seeing compiler errors re: https://github.com/jackhftang/lrucache.nim/blob/master/src/lrucache.nim#L59-L61↵unless `proc len` gets moved to an earlier pos in the module or there is" | "long message, see http://ix.io/3P5Z" => "forward decl for it earlier in the module"
03:01:25FromDiscord<Rika> If you wanna figure it out yourself you could git bisect the compiler
03:01:38FromDiscord<michaelb> sounds fun 😵
03:40:41FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P66
03:41:20FromDiscord<Require Support> (edit) "https://play.nim-lang.org/#ix=3P66" => "https://play.nim-lang.org/#ix=3P67"
03:44:06FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P68
03:44:21FromDiscord<Arathanis> you can also use `cs` instead of `csharp` if you wish, means the same thing
03:44:43FromDiscord<Require Support> In reply to @Arathanis "while i don't know": Thanks sir
03:44:48FromDiscord<Arathanis> you are welcome
03:46:11FromDiscord<Rika> You can change the “stdout” variable by setting a new file
03:46:17FromDiscord<Rika> No, they are not streams
03:49:58FromDiscord<Elegantbeef> Nim does have streams and memory mapped files, https://nim-lang.org/docs/streams.html https://nim-lang.org/docs/memfiles.html though
03:51:37FromDiscord<Rika> Yes but you cannot set the std variables to them
03:57:03FromDiscord<Arathanis> @ElegantBeef took a crack at a typed macro
03:57:34FromDiscord<Elegantbeef> "It got very confused and lost"
03:57:59FromDiscord<Arathanis> you mentioned making a typed macro that uses `sameType` yesterday
03:59:44FromDiscord<Arathanis> so i tried setting that up after work today
04:00:03FromDiscord<Arathanis> was an interesting exercise, `error` is very cool
04:02:08FromDiscord<Elegantbeef> What's it look like?
04:02:52FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6b
04:03:48FromDiscord<Elegantbeef> lol `filterit` exists
04:04:09FromDiscord<Arathanis> i don't really understasnd the implications of `filterit` in this context
04:04:26FromDiscord<Elegantbeef> for `candidates = handelrParams.filterIt(it[^1].sameType(msProcParam[^2]))`
04:04:50FromDiscord<Elegantbeef> I'm laughing at the closure statement and pointing out an alternative
04:05:55FromDiscord<Arathanis> haha yeah i knew there had to be a better way
04:05:57FromDiscord<Require Support> In reply to @Rika "You can change the": Yes, I've been doing that until now but was just wondering if its possible to do it through memorystreams, memfiles, etc.
04:06:00FromDiscord<Arathanis> ive run into that closure problem before
04:06:26FromDiscord<Arathanis> updated code block w/ your suggestion
04:06:28FromDiscord<Arathanis> really cleans it up
04:06:32*supakeen joined #nim
04:06:32FromDiscord<Elegantbeef> Make a memfile or stream then do `stdout.open(memFile.handle)`
04:07:22FromDiscord<Elegantbeef> You also dont check that the return type is empty 😛
04:08:24FromDiscord<Elegantbeef> Anyway looks good!
04:08:57FromDiscord<Arathanis> ill have to add that! and thank you
04:09:25FromDiscord<Arathanis> using the std/sugar anon function syntax lets me not have ot use {.inject.} but I do have to type the params
04:10:47FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/rpY
04:11:37FromDiscord<Elegantbeef> This is where i mention that your handler will not work on `proc doThing(a = "hello")` afaik
04:11:38FromDiscord<Arathanis> yeah, i was also just fiddling with it lol
04:12:42FromDiscord<Arathanis> true, though it doesn't make much sense to me for it to support that since the idea is for it to be given any parameters it will use when called as a handler.
04:12:58FromDiscord<Arathanis> though i can see how you might have some params with defaults you expect to not be bound
04:13:05FromDiscord<Arathanis> it wouldn't be hard to make that ok i think
04:13:26FromDiscord<Arathanis> basically if there is no candidate but it has a default then its fine
04:14:56FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6d
04:15:04FromDiscord<Elegantbeef> I think so
04:15:30FromDiscord<Require Support> Thanks ill test it out
04:17:13FromDiscord<Elegantbeef> probably need to pass `fmWrite`
04:19:00FromDiscord<Arathanis> In reply to @Elegantbeef "probably need to pass": how can i check if the return type is either empty or void
04:19:17FromDiscord<Arathanis> oop
04:19:20FromDiscord<Arathanis> why did it reply to that
04:19:26FromDiscord<Arathanis> must have misclicked
04:19:50FromDiscord<Elegantbeef> `params[0].kind == nnkEmpty`
04:20:06FromDiscord<Elegantbeef> or `params[0].sameType(bindsym"void")`
04:20:41FromDiscord<Arathanis> i tried that and it did not work
04:20:54FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940824553893003264/unknown.png
04:21:01FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940824584108785664/unknown.png
04:21:20FromDiscord<Elegantbeef> `and not`
04:21:37FromDiscord<Arathanis> mmm small omissions totally changing functionality :]
04:21:43FromDiscord<Elegantbeef> if it's void it's `!= nnkEmpty`
04:22:40FromDiscord<Arathanis> ok cool that worked, I was on the right track just made a boolean algebra error
04:23:08FromDiscord<Arathanis> im happy with that, starting to understand the high level concepts. I can forgive myself the occasional boolean algebra error
04:23:18FromDiscord<Arathanis> (edit) "im happy with that, starting to understand ... theconcepts" added "and internalize" | "concepts." => "concepts and ideas."
04:27:54FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6e
04:28:35FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6f
04:28:48FromDiscord<Elegantbeef> `cint memFile.fHandle`
04:29:49FromDiscord<Elegantbeef> Oh nice you need to do `fHandle` on windows and `handle` on \nix
04:30:07FromDiscord<Require Support> ye im on windows
04:30:11FromDiscord<Elegantbeef> No clue what `mapHandle` vs. `fHandle` is
04:31:27FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6g
04:31:42FromDiscord<Elegantbeef> Uh oh
04:33:50FromDiscord<Require Support> mapHandle and fHandle seems to be the same thing
04:34:23FromDiscord<Elegantbeef> I dont know if you can reassign stdout then
04:34:37FromDiscord<Require Support> might go check how std/osproc does it
04:35:00FromDiscord<leorize> btw you can't reassign stdout in nim
04:35:13FromDiscord<leorize> stderr too, for that matter
04:35:32FromDiscord<Require Support> In reply to @leorize "btw you can't reassign": 🥲
04:35:35FromDiscord<leorize> well you can probably do a `reopen`, but it's not very well supported
04:36:30FromDiscord<Require Support> ye i tried it, but that works for redirecting to another file only I think
04:36:36FromDiscord<leorize> yep
04:38:11FromDiscord<leorize> if you are wondering what is osproc's trick, it's simply assigning the input/output handle of the process it's launching to a pipe
04:38:42FromDiscord<leorize> which you can do for the current process on linux with some `dup2`
04:39:09FromDiscord<leorize> on Windows it's not that simple the last time I checked
04:39:15FromDiscord<Require Support> for windows its probably namedpipes?
04:40:10FromDiscord<leorize> the pipe is less of concern here but rather replacing what the handle refers to
04:40:26FromDiscord<Require Support> I see
04:40:39FromDiscord<leorize> on linux you have `dup2()` to do that, I don't know if windows have an equivalent
05:22:17NimEventerNew thread by Mardiyah: How's regex modifier in nim PCRE ?, see https://forum.nim-lang.org/t/8884
05:30:03NimEventerNew question by itil memek cantik: Do a Nim regex modifier just like Perl one, see https://stackoverflow.com/questions/71044343/do-a-nim-regex-modifier-just-like-perl-one
06:37:46FromDiscord<Arathanis> Can you make a macro factory? A procedure that generates and returns a macro?
06:39:52FromDiscord<Elegantbeef> No you can make a procedure that operates on `NimNode`s and returns it
06:39:59FromDiscord<Elegantbeef> So you can just make procedures that do the macro body
06:40:42FromDiscord<Arathanis> Ah ok, I do see lots of macros implemented with the macro as a wrapper but the heavy lifting is several procs
06:41:10FromDiscord<Elegantbeef> It's ideal as it enables code reuse for future features
06:41:15FromDiscord<Elegantbeef> and it breaks them up
06:41:34FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6z
06:41:36FromDiscord<Arathanis> does not work
06:41:44FromDiscord<Elegantbeef> Of course not
06:41:57FromDiscord<Elegantbeef> one `let exampleMacro = macro` makes no sense
06:42:34FromDiscord<Elegantbeef> two what's the purpose of aliasing the macro?
06:43:05FromDiscord<Arathanis> well if you could pass parameters to the factory proc you could do interesting things succinctly
06:43:18FromDiscord<Elegantbeef> I dont follow
06:44:18FromDiscord<Arathanis> and i figured `let exampleMacro = buildMacro()` made sense in the same way you can do it with procs
06:44:40FromDiscord<Elegantbeef> Well macros are compile time only
06:45:06FromDiscord<Elegantbeef> They're not procedures, you cannot take an address of them
06:45:47FromDiscord<Elegantbeef> Assuming you're just wanting to set state for macros, you could make a template that passes the state then you could just use that
06:46:10FromDiscord<Arathanis> oh you could do that, huh?
06:46:13FromDiscord<Arathanis> a template would work
06:46:24FromDiscord<Arathanis> lots of interesting interaction
06:47:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P6A
06:47:31FromDiscord<Elegantbeef> You can use templates or overloads for optional things
06:48:00FromDiscord<Elegantbeef> https://github.com/beef331/constructor/blob/master/src/constructor/defaults.nim#L76-L94 for a real world example
07:03:12FromDiscord<Arathanis> can anonymous procs have more than one statement? what about anonymous procs using std/sugar's `=>` syntax?
07:05:06FromDiscord<Elegantbeef> anonymous procs can have as many statements as normal procs
07:05:20FromDiscord<Elegantbeef> No clue about sugar cause i dont tend to use that
07:07:07FromDiscord<Elegantbeef> Thinking about it you may have to use `()` to make it happy for instance `(a, b: int) => (doThing(a, b); echo("Hello", a, b))`
07:08:08FromDiscord<Elegantbeef> Yes you can make that multilined if you wanted aslong as you have `()`
07:09:03FromDiscord<Arathanis> looks like you need to use `;` as well
07:09:45FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940867046588182578/unknown.png
07:09:57FromDiscord<Elegantbeef> You shouldnt need `;`
07:10:09FromDiscord<Rika> ? why not
07:10:20FromDiscord<Arathanis> well if I remove the semicolons it gets mad lol
07:10:20FromDiscord<Elegantbeef> It's multiline
07:10:38FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940867269955825704/unknown.png
07:11:54FromDiscord<Arathanis> it just wants the one semicolon https://media.discordapp.net/attachments/371759389889003532/940867587925999616/unknown.png
07:11:56FromDiscord<Arathanis> it was lonely
07:12:44FromDiscord<Arathanis> and its cool if the semicolon wants to visit its friend `echo` https://media.discordapp.net/attachments/371759389889003532/940867800019370064/unknown.png
07:13:04FromDiscord<Arathanis> but not `discard`, we hate that guy https://media.discordapp.net/attachments/371759389889003532/940867883532169217/unknown.png
07:13:16FromDiscord<Arathanis> i love this behavior its so weird
07:14:44*PMunch joined #nim
07:14:51FromDiscord<Rika> idk, i personally would never use =>
07:17:15FromDiscord<Arathanis> doesn't make it less weird
07:17:49FromDiscord<Rika> it is weird
07:18:05FromDiscord<Arathanis> god, I can't figure out how to increment a character to the next character
07:18:10FromDiscord<Arathanis> im sure its painfully obvious
07:18:22FromDiscord<Elegantbeef> `char ord(char) + 1`
07:18:30FromDiscord<Arathanis> not as painfull obvious as I thought
07:18:33FromDiscord<Elegantbeef> or `chr.succ`
07:18:37FromDiscord<Arathanis> there it is
07:18:52FromDiscord<Rika> succ deez nuts
07:20:42PMunch-_-
07:21:41FromDiscord<Elegantbeef> "Go pred yourself"
07:22:49FromDiscord<Arathanis> Is there a way to get a generic, guaranteed unused identifier that I can call repeatedly? like an ident factory
07:22:57FromDiscord<Arathanis> well, other than rolling your own of course
07:23:01FromDiscord<Elegantbeef> `genSym`
07:23:32FromDiscord<Arathanis> nice that is very useful
07:26:29FromDiscord<Arathanis> can you give them types?
07:26:44FromDiscord<Elegantbeef> what do you mean it's just a name
07:26:52FromDiscord<Arathanis> yeah im asking the wrong question
07:26:55FromDiscord<Arathanis> an example would be better
07:27:11FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940871433775644742/unknown.png
07:27:12FromDiscord<Arathanis> ->
07:27:25FromDiscord<Arathanis> https://media.discordapp.net/attachments/371759389889003532/940871493833850891/unknown.png
07:29:53FromDiscord<Elegantbeef> do `genSym(nskParam)`
07:30:56FromDiscord<Arathanis> gives me the same error
07:33:18FromDiscord<Elegantbeef> runnable version?
07:34:09FromDiscord<Arathanis> like, source code you can fiddle with?
07:34:17FromDiscord<Elegantbeef> With an example
07:34:30FromDiscord<Arathanis> im just playing with that macro i specified above
07:34:44FromDiscord<Arathanis> instead of declaring my own idents im trying to generate them so i dont need specific names
07:34:45FromDiscord<Elegantbeef> Sure but i want a runnable example i can quickly fix and explain why
07:34:58FromDiscord<Arathanis> oh ok, one sec
07:37:30FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6M
07:38:54FromDiscord<Arathanis> made a small edit
07:38:59FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=3P6P" => "https://play.nim-lang.org/#ix=3P6O"
07:39:18FromDiscord<Arathanis> though i guess i should try and figure that part out myself
07:42:22PMunchHmm, is there no way to get a type name easily in a macro?
07:42:37FromDiscord<Elegantbeef> `getTypeImpl[0]`?
07:42:53PMunchgetTypeInst kinda works, but e.g. for a ValueError it returns a nnkRefTy(nnkSym("ValueError"))
07:43:22FromDiscord<Arathanis> reverted edit, ill try tackling the further work myself first
07:43:28PMunchFor non-ref types it only returns a nnkSym, so getTypeImpl[0] won't work
07:47:55FromDiscord<Elegantbeef> Oh the issue is your names arent used anywhere but the call
07:51:32*jjido joined #nim
07:52:15FromDiscord<Arathanis> ah ok
07:52:31FromDiscord<Arathanis> that error goes away, but i get a redefinition error when i try and use them in the genAst
07:52:35FromDiscord<Arathanis> ill have to tackle this tomorrow
07:53:02FromDiscord<Arathanis> got to: https://media.discordapp.net/attachments/371759389889003532/940877937513730119/unknown.png
07:53:10FromDiscord<Arathanis> resulting in https://media.discordapp.net/attachments/371759389889003532/940877972599107605/unknown.png
08:12:20*Jjp137 quit (Ping timeout: 252 seconds)
08:16:21*Vladar joined #nim
08:23:01*Jjp137 joined #nim
08:37:00*tiorock joined #nim
08:37:00*tiorock quit (Changing host)
08:37:00*tiorock joined #nim
08:37:00*rockcavera is now known as Guest6517
08:37:00*tiorock is now known as rockcavera
08:39:39*Guest6517 quit (Ping timeout: 256 seconds)
08:41:55PMunchWhat's the easiest way to get an ISO timestamp in Nim?
08:42:20PMunchI guess now.format(<ISO format string here>) would work, but I was wondering if that format string was defined somewhere convenient?
08:42:34PMunchI mean now.format(iso) would be great
08:48:39PMunchOh neat, I triggered a compiler error, been a while since I've seen one of those
08:49:26FromDiscord<Elegantbeef> Fun fun fun
08:49:46FromDiscord<Elegantbeef> Is this to do with that logging library?
08:50:11PMunchHaha, yes
08:50:27PMunchI was doing something I expected to fail, but I expected to get a nice error message
09:02:25*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
09:06:55NimEventerNew Nimble package! tim - Really lightweight template engine, see https://github.com/openpeep/tim
09:13:56*jjido joined #nim
09:14:24*vicecea quit (Remote host closed the connection)
09:14:52*vicecea joined #nim
09:39:50FromDiscord<Waldecir Santos> Is it possible to use a macro as a "type", e.g:
09:40:07FromDiscord<Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P7f
09:40:23FromDiscord<Elegantbeef> Yes you can use macro/templates as a type annotation
09:42:04FromDiscord<Waldecir Santos> Hmm do you have one example ? I tried and got this
09:42:05FromDiscord<Waldecir Santos> https://media.discordapp.net/attachments/371759389889003532/940905385466949642/unknown.png
09:42:21FromDiscord<planetis> guys should I add usemalloc in the benchmarks\: https://github.com/hanabi1224/Programming-Language-Benchmarks/pull/245 ?
09:42:25FromDiscord<Waldecir Santos> or do I need to return a `nk?????` that represents a string ?
09:42:47FromDiscord<planetis> you need to return untyped
09:43:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P7g
09:43:42FromDiscord<demotomohiro> `name; myType()` doesn't work?
09:44:02FromDiscord<demotomohiro> `name: myType()`
09:44:10FromDiscord<Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P7h
09:44:17FromDiscord<Waldecir Santos> https://media.discordapp.net/attachments/371759389889003532/940905938783703050/unknown.png
09:45:01FromDiscord<Elegantbeef> You didnt invoke it
09:45:07FromDiscord<Elegantbeef> `name: myType()`
09:45:19FromDiscord<Waldecir Santos> Oh right, thank you
09:48:00FromDiscord<Elegantbeef> May i ask what you hope the macro to do?
09:50:49FromDiscord<Elegantbeef> I know it's in relation to your problem yesterday, just curious
09:52:04FromDiscord<Waldecir Santos> Yeah it's about yesterdays problem, I'm just messing around with crazy ideas at this moment, if non work, I'll create a new full macro/block for model declaration, I really want to leave this as close as possible as django works, to make entrance easy to nim+web development
09:52:12FromDiscord<Waldecir Santos> But tbh my main goal is to learn Nim.
09:53:27FromDiscord<Elegantbeef> Well jumping into macros headfirst is one way to learn it 😀
09:54:15PMunchIs there an easy way to get the name of the current module?
09:55:31FromDiscord<Elegantbeef> There is not that i know of you need to have a symbol of the variable to propagate up the owners to find
09:55:42*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
09:56:40PMunchWell that's annoying..
09:57:03FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/Yzs
09:59:24PMunchI mean you can sorta get it from instantiationInfo
10:21:20*Vladar quit (Quit: Leaving)
10:23:20FromDiscord<vindaar> @PMunch\: I recently started to embrace first a `typeKind` call on a node and then dispatch based on that. Then have a proc extracting the type from a typedesc, an alias, a generic insantiation, etc. Makes "type extraction" code a bit more sane. Problem is still that getting the type is very tricky, but partially that is because the type one wants is often very specific and not exactly the first thing that might come up
10:24:28*Vladar joined #nim
10:25:58PMunchYeah inspecting the whole type hierarchy is a bit tricky
10:27:56FromDiscord<Elegantbeef> Really we need an expanded macros module that has all that stuff
10:30:50FromDiscord<Elegantbeef> Need a `micros` module which makes your macros smaller 😛
10:31:18FromDiscord<vindaar> sent a long message, see http://ix.io/3P7u
10:32:02FromDiscord<Elegantbeef> disruptek's assume handles that all with options
10:32:23FromDiscord<vindaar> have a link?
10:32:28FromDiscord<Elegantbeef> https://github.com/disruptek/assume/blob/master/assume/typeit.nim#L5-L12
10:32:59FromDiscord<Elegantbeef> This isnt identical this is about the fields, but the same thing can be used for your above logic
10:33:32FromDiscord<vindaar> yeah, something like that is probably the right approach
10:33:57FromDiscord<Elegantbeef> I mean it's just one part of the thing that makes sense
10:34:58FromDiscord<Elegantbeef> more named things like `returnType` or an `parameters` which yields `(name, type, default)`
10:35:54FromDiscord<vindaar> yep, that would also be very helpful
10:36:14FromDiscord<vindaar> everything that helps to avoid having to carefully deal with the actual tree structure by hand each time would be a big win
10:36:33FromDiscord<Elegantbeef> Yea
10:36:51FromDiscord<vindaar> biggest problem is that in every new macro, I'm never certain what kind of edge cases might come up that will break the code
10:37:24FromDiscord<Elegantbeef> Yea being a compiler dev isnt fun 😛
10:39:22FromDiscord<Elegantbeef> Ideally you replace most indexing with properties but that's hellish 😀
10:39:47FromDiscord<vindaar> properties in what sense?
10:40:06FromDiscord<Elegantbeef> `myProcDef.body = newStmtList()`
10:40:32FromDiscord<Elegantbeef> `myIdentDef.typ`
10:40:34FromDiscord<vindaar> ah, ok
10:41:16FromDiscord<Elegantbeef> I'm kinda partial to converting common NimNodes into distinct types and work with them that way
10:41:53FromDiscord<Elegantbeef> The fact all the Nimnodes are exposed to everyone as just an undescript box is absurd imo
10:42:44FromDiscord<vindaar> well, I think it is good to have that access, but it would be nice to have a type safe layer on top of that
10:43:38FromDiscord<Elegantbeef> Anyway i'm off, i dont need to talk about this more and encourage myself to do something else
10:43:49FromDiscord<Elegantbeef> Though i mean i havent touched my game in a few days so clearly that's not working 😀
10:43:49FromDiscord<vindaar> haha, fair enough
10:59:36PMunchOkay, I got a bit carried away: https://github.com/PMunch/superlog
11:04:17FromDiscord<MrOkram> Hello, quick question, is it somehow possible to bind a Nim http server to a specific network interface ? (Linux env)
11:11:56*jjido joined #nim
11:17:15*tinystoat is now known as typoholic
11:53:14*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
12:06:01*supakeen quit (Quit: WeeChat 3.4)
12:06:31*supakeen joined #nim
12:10:05*rockcavera quit (Read error: Connection reset by peer)
12:10:29*rockcavera joined #nim
12:10:29*rockcavera quit (Changing host)
12:10:29*rockcavera joined #nim
12:20:12PMunch@MrOkram, yes, it's just a matter of listening to the correct IP
12:22:29NimEventerNew thread by Mardiyah: Any practical configuration for Nim "REPL", see https://forum.nim-lang.org/t/8885
12:42:45*jmdaemon quit (Ping timeout: 256 seconds)
12:48:30*arkurious joined #nim
13:09:58FromDiscord<Rika> In reply to @PMunch "Okay, I got a": Nice
13:10:16PMunchIt's a pretty neat concept
13:11:50PMunchBut I think the `log` macro should just grab whatever is in activeLoggers and the `register` proc should do all the processing. This way it would be possible to define some stuff which is currently not possible.
13:13:40FromDiscord<Rika> maybe it should be easy to filter modules
13:13:48PMunchFilter modules?
13:14:01FromDiscord<Rika> easier since you already can distinguish by instinfo
13:14:57PMunchOh yeah, I was considering to add a Module type which you could insert to get the module name as a string or something
13:15:19PMunchBut getting the currently executing module is surprisingly cumbersome
13:15:30FromDiscord<Rika> Ah, loggers are per loggable type
13:15:38FromDiscord<Rika> thats kinda crazy
13:16:31FromDiscord<Rika> maybe you should implement/encourage the usage of some common loggable types
13:16:36PMunchYou can define one over multiple types as well, but then you of course need to use `when x is Y` to determine which fields you have
13:17:34PMunchYeah I thought about maybe defining a LogMessage(msg: string) or something like that. But I'm a bit afraid that that would mean everyone would just use that and then you can't filter anything without looking at instantiationInfo any more
13:18:11PMunchI guess it could be a LogMessage[T: static[string]](msg: string, module: T) though
13:18:32PMunchWith a nice constructor that grabs the current module
13:19:05PMunchThe current implementation doesn't support registerLogger(someType[Generic]) though
13:20:18PMunchThe activeLoggers table should really map from signatureHash to code instead of a string that I manually build from the module
13:21:59PMunchBut then it might be hard to support registering all the versions of a generic type..
13:25:16PMunchOh no, that should be fine, I think
13:29:30PMunchYeah, since you get a BracketExpr you should be able to extract both the hash for the generic type, and the generic argument, so you'd just need a slight change to the table and a minor fix in the registering macro to support it.
13:30:42PMunchIn fact it would already work if you just made a type alias for your specific version of the generic
13:58:57NimEventerNew thread by Mardiyah: To insert regex pattern into another, see https://forum.nim-lang.org/t/8886
14:01:58PMunch@Rika, in fact the generic version of LogMessage would work really well. A library could then just `import superlog` which would contain the definition for the generic message and a `log` template which took a string and grabbed the module automatically. Then the user library could register a logger for either the generic type or it could register a logger for a specific module.
14:03:00PMunchSo if you just want to log some strings quick and dirty you don't have to create a separate loggable types file, and the user can then filter messages based on module
14:05:02*fvs joined #nim
14:16:03PMunchAdded a small note on the various improvements that could be made: https://github.com/PMunch/superlog#improvements
14:16:47*Gustavo6046 joined #nim
14:19:38FromDiscord<Rika> In reply to @PMunch "<@259277943275126785>, in fact the": ill try to understand you at another time, my brain isnt working for some reason so im prolly gonna go back to sleep
14:20:25PMunchHaha, sorry for the monologue. I just start thinking about this and my mind fires on all cylinders :P
14:23:37FromDiscord<Rika> i mean thats good innit
14:23:55FromDiscord<Rika> i currently understood nothing and i dont know why, i should have
14:24:10FromDiscord<Rika> i also have one hell of a headache so i should probably go back sleep
14:24:11FromDiscord<Rika> (edit) "i also have one hell of a headache so i should probably go back ... sleep" added "to"
14:35:01*Gustavo6046 quit (Quit: Leaving)
14:56:18PMunchDamn it, I can't get the symbol for a module without triggering an import..
14:59:30PMunchI wanted to support something like `registerLogger(LogMessage[module(someModule/someModule)], myLogger)` where `module` would be a macro to get the signatureHash of the module symbol. However `someModule/someModule` isn't an import statement, so I can't just use that. By making `module` a template which called a macro on `import someModule/someModule` I managed to extract a module symbol for `someModule` but that triggers Nim to process the file (which expands
14:59:30PMunchthe log statements to empty ones since I haven't registered a logger yet).
15:02:18FromDiscord<narimiran> Nim v1.6.4 is out!! https://nim-lang.org/blog/2022/02/08/version-164-released.html
15:05:39*PMunch quit (Quit: Leaving)
15:09:09NimEventerNew thread by Miran: Nim 1.6.4 released, see https://forum.nim-lang.org/t/8887
16:16:37FromDiscord<Waldecir Santos> On a macro how do I return a type ? I can do with string using `ident"string"`. But not sure how to do for my custom type
16:27:20*Vladar quit (Quit: Leaving)
17:15:37NimEventerNew post on r/nim by miran1: Nim 1.6.4 released, see https://reddit.com/r/nim/comments/soinu5/nim_164_released/
17:29:48FromDiscord<untoreh> sent a code paste, see https://play.nim-lang.org/#ix=3P9u
17:30:36FromDiscord<untoreh> do I have to hash `w` ?
17:33:40FromDiscord<Rika> its because you're selectively importing
17:33:58FromDiscord<Rika> `from sets import toHashSet, contains` or more ideally just `import sets`
18:22:43*Jjp137 quit (Quit: Leaving)
18:22:50*Jjp137 joined #nim
18:23:43*Jjp137 quit (Client Quit)
18:23:50*Jjp137 joined #nim
18:27:00FromDiscord<untoreh> sent a code paste, see https://play.nim-lang.org/#ix=3P9R
18:30:07*Nuc1eoN quit (Remote host closed the connection)
18:31:13FromDiscord<Rika> how do you measure the time
18:32:03FromDiscord<Rika> going from python to nim to python has overhead
18:33:00*Nuc1eoN joined #nim
18:36:07arkanoidis there an implicit limit on the amount of await I can do at the same time on a I/O bound system?
18:56:02*vicfred joined #nim
18:59:18FromDiscord<auxym> I would assume the limit is just when you become cpu-bound or memory-bound
19:25:42*dtomato quit (Quit: The Lounge - https://thelounge.chat)
19:26:05*dtomato joined #nim
20:10:36*tiorock joined #nim
20:10:36*tiorock quit (Changing host)
20:10:36*tiorock joined #nim
20:10:36*rockcavera is now known as Guest3024
20:10:36*Guest3024 quit (Killed (molybdenum.libera.chat (Nickname regained by services)))
20:10:36*tiorock is now known as rockcavera
20:10:38*vicecea quit (Remote host closed the connection)
20:11:09*vicecea joined #nim
20:11:35FromDiscord<Waldecir Santos> What NimNode should I use in a macro to return a type ? I know how to do strings with `ident"string"` but I need to do it with my custom type, but no luck
20:12:04*tiorock joined #nim
20:12:04*tiorock quit (Changing host)
20:12:04*tiorock joined #nim
20:12:04*rockcavera is now known as Guest7790
20:12:04*tiorock is now known as rockcavera
20:13:28Amun-RaI check the code with dumpAst in reproduce it in macro
20:15:17*Guest7790 quit (Ping timeout: 240 seconds)
20:44:46*jjido joined #nim
20:48:56FromDiscord<Waldecir Santos> Yeah I tried but there is a `StrLit` and not sure how to adapt to my scenario
20:52:08Amun-RaI guess, the macro wizard (aka Elegantbeef) is asleep :>
21:07:08FromDiscord<kevin> Is there a good method to convert a `cstring` into a `string` if I know how long the `cstring` is?
21:07:22FromDiscord<kevin> My `cstring` may or may not have null bytes in it :/
21:07:39Amun-Rakevin: $foo
21:07:53FromDiscord<kevin> Cuts off on null bytes in the string unforunately
21:08:03FromDiscord<kevin> so only up until the first null byte
21:08:11Amun-Raah
21:10:03Amun-RaI guess newStringOfCap + .add
21:14:42FromDiscord<vindaar> @Waldecir Santos\: can you clarify what it is you're trying to do?
21:15:00FromDiscord<vindaar> normally it should be enough to just return an ident of the type you want
21:15:25FromDiscord<vindaar> doesn't matter if it's a custom type or not. Of course the type must exist (otherwise you need to generate it of course)
21:27:05FromDiscord<vindaar> @untoreh\: first of all compile with `-d:danger` instead of `--opt:speed` if you want the best performance. Second, python's string handling is relatively fast. Third, if you really want the best performance, you shouldn't use things like `split` in the first place, but rather parse and process the data at the same time
21:40:00*jmdaemon joined #nim
21:45:46*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
21:47:36*jmdaemon joined #nim
21:50:35FromDiscord<ckennedy> https://play.nim-lang.org/#ix=3Paz why does this seem to pass a copy of the `seq` (things) instead of a reference?
21:53:54FromDiscord<ckennedy> If I dereference things at the `seq.add` call site it seems work; `things[].add(...)` instead.
22:00:43FromDiscord<Elegantbeef> You're dereferencing the ref and storing it in a copy
22:01:12FromDiscord<Elegantbeef> `var a = somRef[]` makes `a` a non reference value type
22:01:17FromDiscord<Elegantbeef> @ckennedy\: ^
22:01:58FromDiscord<Waldecir Santos> In reply to @vindaar "<@121971538898452482>\: can you clarify": I'm trying to do this https://play.nim-lang.org/#ix=3PaD
22:02:41FromDiscord<Elegantbeef> There you go
22:02:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3PaE
22:03:18FromDiscord<Elegantbeef> you can also do `return bindSym $mType` i believe
22:03:19FromDiscord<Waldecir Santos> oh I thought bindSym was meant to bind functions
22:03:39FromDiscord<Elegantbeef> `bindSym` can bind any symbol on the scope of the macro
22:03:59FromDiscord<Waldecir Santos> Nice, thank you !
22:04:54FromDiscord<ckennedy> In reply to @Elegantbeef "You're dereferencing the ref": So if I'm working with a reference to a seq or array, is using `things[].add` to be expected? Or am I engaging in some kind of anti-pattern?
22:05:26FromDiscord<Elegantbeef> `[]` is to be expected, but you can always make your own `.add` it
22:06:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3PaF
22:07:59FromDiscord<Elegantbeef> There is an experimental auto dereference but i'll be deprecated in afaik
22:08:00FromDiscord<vindaar> @Waldecir Santos, [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org) but you don't even need `bindSym` here
22:08:01FromDiscord<ynfle> In reply to @ckennedy "So if I'm working": You shouldn't need to deref, it automatically derefs for field accesing
22:08:12FromDiscord<Elegantbeef> `add` isnt a field
22:08:43FromDiscord<ckennedy> In reply to @Elegantbeef "`add` isnt a field": That's what I ran into, `seq.add` and `enumerate` throw an error if it's a `ref`
22:08:58FromDiscord<Waldecir Santos> In reply to @vindaar "<@121971538898452482>, [Elegantbeef](https://matrix": not sure what you mean
22:09:02FromDiscord<Elegantbeef> I showed them an example with an ident and they apparently didnt want to use it 😛
22:09:08FromDiscord<Elegantbeef> you can do `ident"MyType"`
22:09:27FromDiscord<vindaar> Ah, missed that 😁
22:09:27FromDiscord<Elegantbeef> I guess you can do `return MyType.getType`?
22:09:28FromDiscord<Waldecir Santos> It didn't worked @@ let me try again
22:09:40FromDiscord<Waldecir Santos> bindSym worked
22:09:50FromDiscord<Elegantbeef> It will not work if the `MyType` is not exported
22:09:58FromDiscord<Elegantbeef> If `MyType` isnt exported then you need bindsym
22:10:31FromDiscord<Waldecir Santos> well ident is working now too, shame on me
22:10:47FromDiscord<Elegantbeef> Well if you move them to different modules it'll fail, so take that into account
22:10:53FromDiscord<Waldecir Santos> What is the diferente between `ident` and `bindSym`. 🤔
22:11:06FromDiscord<Elegantbeef> `ident` is an untyped identifier
22:11:27FromDiscord<Elegantbeef> `bindSym` finds the symbol in the scope of the macro and grabs it, holding onto a typed identifier
22:13:35FromDiscord<Waldecir Santos> Thank you !
22:46:28FromDiscord<amadan> https://play.nim-lang.org/#ix=3PaK↵When I return a sym to a proc it keeps complaining that I'm not using it.↵Anyone know what the issue might be?
22:47:04FromDiscord<Elegantbeef> `macro foo(x: typed): untyped =`
22:48:56FromDiscord<amadan> Epic, thanks for that↵Always thought macros returned untyped by default
23:17:46FromDiscord<rainbowasteroids> What is the difference between `Exception` and `CatchableError`?
23:22:21*rockcavera quit (Remote host closed the connection)
23:27:14FromDiscord<konsumlamm> an `Exception` is not necessarily catchable
23:31:02FromDiscord<Elegantbeef> Exceptions are catchable are they not?
23:31:14FromDiscord<Elegantbeef> Ah nvm
23:31:36FromDiscord<Elegantbeef> Exception is the base type that Defect and CatchableError come form
23:31:58FromDiscord<Elegantbeef> Defects are not to be caught and signify a programmer error, CatchableErrors are safe to catche
23:33:37FromDiscord<rainbowasteroids> So, does `except` not work on objects that don't inherit from `CatchableError`?
23:33:58FromDiscord<Elegantbeef> Right
23:34:14FromDiscord<Elegantbeef> Well `except` works for `Defect` but only in some dialects
23:34:17FromDiscord<Elegantbeef> Which is why you dont use it for them
23:34:26FromDiscord<Elegantbeef> They're better prevented in otherways
23:35:33*rockcavera joined #nim
23:35:33*rockcavera quit (Changing host)
23:35:33*rockcavera joined #nim
23:40:39*jmdaemon quit (Ping timeout: 256 seconds)
23:42:46FromDiscord<konsumlamm> it's only guaranteed to work for `CatchableError`s
23:45:08*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
23:55:50*jmdaemon joined #nim