00:07:50 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
00:12:29 | FromDiscord | <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:10 | FromDiscord | <michaelb> sent a long message, see http://ix.io/3P5X |
02:59:50 | FromDiscord | <michaelb> (edit) "http://ix.io/3P5X" => "https://paste.rs/xrk" |
03:00:35 | FromDiscord | <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:55 | FromDiscord | <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:25 | FromDiscord | <Rika> If you wanna figure it out yourself you could git bisect the compiler |
03:01:38 | FromDiscord | <michaelb> sounds fun 😵 |
03:40:41 | FromDiscord | <Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P66 |
03:41:20 | FromDiscord | <Require Support> (edit) "https://play.nim-lang.org/#ix=3P66" => "https://play.nim-lang.org/#ix=3P67" |
03:44:06 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P68 |
03:44:21 | FromDiscord | <Arathanis> you can also use `cs` instead of `csharp` if you wish, means the same thing |
03:44:43 | FromDiscord | <Require Support> In reply to @Arathanis "while i don't know": Thanks sir |
03:44:48 | FromDiscord | <Arathanis> you are welcome |
03:46:11 | FromDiscord | <Rika> You can change the “stdout” variable by setting a new file |
03:46:17 | FromDiscord | <Rika> No, they are not streams |
03:49:58 | FromDiscord | <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:37 | FromDiscord | <Rika> Yes but you cannot set the std variables to them |
03:57:03 | FromDiscord | <Arathanis> @ElegantBeef took a crack at a typed macro |
03:57:34 | FromDiscord | <Elegantbeef> "It got very confused and lost" |
03:57:59 | FromDiscord | <Arathanis> you mentioned making a typed macro that uses `sameType` yesterday |
03:59:44 | FromDiscord | <Arathanis> so i tried setting that up after work today |
04:00:03 | FromDiscord | <Arathanis> was an interesting exercise, `error` is very cool |
04:02:08 | FromDiscord | <Elegantbeef> What's it look like? |
04:02:52 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6b |
04:03:48 | FromDiscord | <Elegantbeef> lol `filterit` exists |
04:04:09 | FromDiscord | <Arathanis> i don't really understasnd the implications of `filterit` in this context |
04:04:26 | FromDiscord | <Elegantbeef> for `candidates = handelrParams.filterIt(it[^1].sameType(msProcParam[^2]))` |
04:04:50 | FromDiscord | <Elegantbeef> I'm laughing at the closure statement and pointing out an alternative |
04:05:55 | FromDiscord | <Arathanis> haha yeah i knew there had to be a better way |
04:05:57 | FromDiscord | <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:00 | FromDiscord | <Arathanis> ive run into that closure problem before |
04:06:26 | FromDiscord | <Arathanis> updated code block w/ your suggestion |
04:06:28 | FromDiscord | <Arathanis> really cleans it up |
04:06:32 | * | supakeen joined #nim |
04:06:32 | FromDiscord | <Elegantbeef> Make a memfile or stream then do `stdout.open(memFile.handle)` |
04:07:22 | FromDiscord | <Elegantbeef> You also dont check that the return type is empty 😛 |
04:08:24 | FromDiscord | <Elegantbeef> Anyway looks good! |
04:08:57 | FromDiscord | <Arathanis> ill have to add that! and thank you |
04:09:25 | FromDiscord | <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:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/rpY |
04:11:37 | FromDiscord | <Elegantbeef> This is where i mention that your handler will not work on `proc doThing(a = "hello")` afaik |
04:11:38 | FromDiscord | <Arathanis> yeah, i was also just fiddling with it lol |
04:12:42 | FromDiscord | <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:58 | FromDiscord | <Arathanis> though i can see how you might have some params with defaults you expect to not be bound |
04:13:05 | FromDiscord | <Arathanis> it wouldn't be hard to make that ok i think |
04:13:26 | FromDiscord | <Arathanis> basically if there is no candidate but it has a default then its fine |
04:14:56 | FromDiscord | <Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6d |
04:15:04 | FromDiscord | <Elegantbeef> I think so |
04:15:30 | FromDiscord | <Require Support> Thanks ill test it out |
04:17:13 | FromDiscord | <Elegantbeef> probably need to pass `fmWrite` |
04:19:00 | FromDiscord | <Arathanis> In reply to @Elegantbeef "probably need to pass": how can i check if the return type is either empty or void |
04:19:17 | FromDiscord | <Arathanis> oop |
04:19:20 | FromDiscord | <Arathanis> why did it reply to that |
04:19:26 | FromDiscord | <Arathanis> must have misclicked |
04:19:50 | FromDiscord | <Elegantbeef> `params[0].kind == nnkEmpty` |
04:20:06 | FromDiscord | <Elegantbeef> or `params[0].sameType(bindsym"void")` |
04:20:41 | FromDiscord | <Arathanis> i tried that and it did not work |
04:20:54 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940824553893003264/unknown.png |
04:21:01 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940824584108785664/unknown.png |
04:21:20 | FromDiscord | <Elegantbeef> `and not` |
04:21:37 | FromDiscord | <Arathanis> mmm small omissions totally changing functionality :] |
04:21:43 | FromDiscord | <Elegantbeef> if it's void it's `!= nnkEmpty` |
04:22:40 | FromDiscord | <Arathanis> ok cool that worked, I was on the right track just made a boolean algebra error |
04:23:08 | FromDiscord | <Arathanis> im happy with that, starting to understand the high level concepts. I can forgive myself the occasional boolean algebra error |
04:23:18 | FromDiscord | <Arathanis> (edit) "im happy with that, starting to understand ... theconcepts" added "and internalize" | "concepts." => "concepts and ideas." |
04:27:54 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6e |
04:28:35 | FromDiscord | <Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6f |
04:28:48 | FromDiscord | <Elegantbeef> `cint memFile.fHandle` |
04:29:49 | FromDiscord | <Elegantbeef> Oh nice you need to do `fHandle` on windows and `handle` on \nix |
04:30:07 | FromDiscord | <Require Support> ye im on windows |
04:30:11 | FromDiscord | <Elegantbeef> No clue what `mapHandle` vs. `fHandle` is |
04:31:27 | FromDiscord | <Require Support> sent a code paste, see https://play.nim-lang.org/#ix=3P6g |
04:31:42 | FromDiscord | <Elegantbeef> Uh oh |
04:33:50 | FromDiscord | <Require Support> mapHandle and fHandle seems to be the same thing |
04:34:23 | FromDiscord | <Elegantbeef> I dont know if you can reassign stdout then |
04:34:37 | FromDiscord | <Require Support> might go check how std/osproc does it |
04:35:00 | FromDiscord | <leorize> btw you can't reassign stdout in nim |
04:35:13 | FromDiscord | <leorize> stderr too, for that matter |
04:35:32 | FromDiscord | <Require Support> In reply to @leorize "btw you can't reassign": 🥲 |
04:35:35 | FromDiscord | <leorize> well you can probably do a `reopen`, but it's not very well supported |
04:36:30 | FromDiscord | <Require Support> ye i tried it, but that works for redirecting to another file only I think |
04:36:36 | FromDiscord | <leorize> yep |
04:38:11 | FromDiscord | <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:42 | FromDiscord | <leorize> which you can do for the current process on linux with some `dup2` |
04:39:09 | FromDiscord | <leorize> on Windows it's not that simple the last time I checked |
04:39:15 | FromDiscord | <Require Support> for windows its probably namedpipes? |
04:40:10 | FromDiscord | <leorize> the pipe is less of concern here but rather replacing what the handle refers to |
04:40:26 | FromDiscord | <Require Support> I see |
04:40:39 | FromDiscord | <leorize> on linux you have `dup2()` to do that, I don't know if windows have an equivalent |
05:22:17 | NimEventer | New thread by Mardiyah: How's regex modifier in nim PCRE ?, see https://forum.nim-lang.org/t/8884 |
05:30:03 | NimEventer | New 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:46 | FromDiscord | <Arathanis> Can you make a macro factory? A procedure that generates and returns a macro? |
06:39:52 | FromDiscord | <Elegantbeef> No you can make a procedure that operates on `NimNode`s and returns it |
06:39:59 | FromDiscord | <Elegantbeef> So you can just make procedures that do the macro body |
06:40:42 | FromDiscord | <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:10 | FromDiscord | <Elegantbeef> It's ideal as it enables code reuse for future features |
06:41:15 | FromDiscord | <Elegantbeef> and it breaks them up |
06:41:34 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6z |
06:41:36 | FromDiscord | <Arathanis> does not work |
06:41:44 | FromDiscord | <Elegantbeef> Of course not |
06:41:57 | FromDiscord | <Elegantbeef> one `let exampleMacro = macro` makes no sense |
06:42:34 | FromDiscord | <Elegantbeef> two what's the purpose of aliasing the macro? |
06:43:05 | FromDiscord | <Arathanis> well if you could pass parameters to the factory proc you could do interesting things succinctly |
06:43:18 | FromDiscord | <Elegantbeef> I dont follow |
06:44:18 | FromDiscord | <Arathanis> and i figured `let exampleMacro = buildMacro()` made sense in the same way you can do it with procs |
06:44:40 | FromDiscord | <Elegantbeef> Well macros are compile time only |
06:45:06 | FromDiscord | <Elegantbeef> They're not procedures, you cannot take an address of them |
06:45:47 | FromDiscord | <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:10 | FromDiscord | <Arathanis> oh you could do that, huh? |
06:46:13 | FromDiscord | <Arathanis> a template would work |
06:46:24 | FromDiscord | <Arathanis> lots of interesting interaction |
06:47:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P6A |
06:47:31 | FromDiscord | <Elegantbeef> You can use templates or overloads for optional things |
06:48:00 | FromDiscord | <Elegantbeef> https://github.com/beef331/constructor/blob/master/src/constructor/defaults.nim#L76-L94 for a real world example |
07:03:12 | FromDiscord | <Arathanis> can anonymous procs have more than one statement? what about anonymous procs using std/sugar's `=>` syntax? |
07:05:06 | FromDiscord | <Elegantbeef> anonymous procs can have as many statements as normal procs |
07:05:20 | FromDiscord | <Elegantbeef> No clue about sugar cause i dont tend to use that |
07:07:07 | FromDiscord | <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:08 | FromDiscord | <Elegantbeef> Yes you can make that multilined if you wanted aslong as you have `()` |
07:09:03 | FromDiscord | <Arathanis> looks like you need to use `;` as well |
07:09:45 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940867046588182578/unknown.png |
07:09:57 | FromDiscord | <Elegantbeef> You shouldnt need `;` |
07:10:09 | FromDiscord | <Rika> ? why not |
07:10:20 | FromDiscord | <Arathanis> well if I remove the semicolons it gets mad lol |
07:10:20 | FromDiscord | <Elegantbeef> It's multiline |
07:10:38 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940867269955825704/unknown.png |
07:11:54 | FromDiscord | <Arathanis> it just wants the one semicolon https://media.discordapp.net/attachments/371759389889003532/940867587925999616/unknown.png |
07:11:56 | FromDiscord | <Arathanis> it was lonely |
07:12:44 | FromDiscord | <Arathanis> and its cool if the semicolon wants to visit its friend `echo` https://media.discordapp.net/attachments/371759389889003532/940867800019370064/unknown.png |
07:13:04 | FromDiscord | <Arathanis> but not `discard`, we hate that guy https://media.discordapp.net/attachments/371759389889003532/940867883532169217/unknown.png |
07:13:16 | FromDiscord | <Arathanis> i love this behavior its so weird |
07:14:44 | * | PMunch joined #nim |
07:14:51 | FromDiscord | <Rika> idk, i personally would never use => |
07:17:15 | FromDiscord | <Arathanis> doesn't make it less weird |
07:17:49 | FromDiscord | <Rika> it is weird |
07:18:05 | FromDiscord | <Arathanis> god, I can't figure out how to increment a character to the next character |
07:18:10 | FromDiscord | <Arathanis> im sure its painfully obvious |
07:18:22 | FromDiscord | <Elegantbeef> `char ord(char) + 1` |
07:18:30 | FromDiscord | <Arathanis> not as painfull obvious as I thought |
07:18:33 | FromDiscord | <Elegantbeef> or `chr.succ` |
07:18:37 | FromDiscord | <Arathanis> there it is |
07:18:52 | FromDiscord | <Rika> succ deez nuts |
07:20:42 | PMunch | -_- |
07:21:41 | FromDiscord | <Elegantbeef> "Go pred yourself" |
07:22:49 | FromDiscord | <Arathanis> Is there a way to get a generic, guaranteed unused identifier that I can call repeatedly? like an ident factory |
07:22:57 | FromDiscord | <Arathanis> well, other than rolling your own of course |
07:23:01 | FromDiscord | <Elegantbeef> `genSym` |
07:23:32 | FromDiscord | <Arathanis> nice that is very useful |
07:26:29 | FromDiscord | <Arathanis> can you give them types? |
07:26:44 | FromDiscord | <Elegantbeef> what do you mean it's just a name |
07:26:52 | FromDiscord | <Arathanis> yeah im asking the wrong question |
07:26:55 | FromDiscord | <Arathanis> an example would be better |
07:27:11 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940871433775644742/unknown.png |
07:27:12 | FromDiscord | <Arathanis> -> |
07:27:25 | FromDiscord | <Arathanis> https://media.discordapp.net/attachments/371759389889003532/940871493833850891/unknown.png |
07:29:53 | FromDiscord | <Elegantbeef> do `genSym(nskParam)` |
07:30:56 | FromDiscord | <Arathanis> gives me the same error |
07:33:18 | FromDiscord | <Elegantbeef> runnable version? |
07:34:09 | FromDiscord | <Arathanis> like, source code you can fiddle with? |
07:34:17 | FromDiscord | <Elegantbeef> With an example |
07:34:30 | FromDiscord | <Arathanis> im just playing with that macro i specified above |
07:34:44 | FromDiscord | <Arathanis> instead of declaring my own idents im trying to generate them so i dont need specific names |
07:34:45 | FromDiscord | <Elegantbeef> Sure but i want a runnable example i can quickly fix and explain why |
07:34:58 | FromDiscord | <Arathanis> oh ok, one sec |
07:37:30 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=3P6M |
07:38:54 | FromDiscord | <Arathanis> made a small edit |
07:38:59 | FromDiscord | <Arathanis> (edit) "https://play.nim-lang.org/#ix=3P6P" => "https://play.nim-lang.org/#ix=3P6O" |
07:39:18 | FromDiscord | <Arathanis> though i guess i should try and figure that part out myself |
07:42:22 | PMunch | Hmm, is there no way to get a type name easily in a macro? |
07:42:37 | FromDiscord | <Elegantbeef> `getTypeImpl[0]`? |
07:42:53 | PMunch | getTypeInst kinda works, but e.g. for a ValueError it returns a nnkRefTy(nnkSym("ValueError")) |
07:43:22 | FromDiscord | <Arathanis> reverted edit, ill try tackling the further work myself first |
07:43:28 | PMunch | For non-ref types it only returns a nnkSym, so getTypeImpl[0] won't work |
07:47:55 | FromDiscord | <Elegantbeef> Oh the issue is your names arent used anywhere but the call |
07:51:32 | * | jjido joined #nim |
07:52:15 | FromDiscord | <Arathanis> ah ok |
07:52:31 | FromDiscord | <Arathanis> that error goes away, but i get a redefinition error when i try and use them in the genAst |
07:52:35 | FromDiscord | <Arathanis> ill have to tackle this tomorrow |
07:53:02 | FromDiscord | <Arathanis> got to: https://media.discordapp.net/attachments/371759389889003532/940877937513730119/unknown.png |
07:53:10 | FromDiscord | <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:55 | PMunch | What's the easiest way to get an ISO timestamp in Nim? |
08:42:20 | PMunch | I guess now.format(<ISO format string here>) would work, but I was wondering if that format string was defined somewhere convenient? |
08:42:34 | PMunch | I mean now.format(iso) would be great |
08:48:39 | PMunch | Oh neat, I triggered a compiler error, been a while since I've seen one of those |
08:49:26 | FromDiscord | <Elegantbeef> Fun fun fun |
08:49:46 | FromDiscord | <Elegantbeef> Is this to do with that logging library? |
08:50:11 | PMunch | Haha, yes |
08:50:27 | PMunch | I 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:55 | NimEventer | New 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:50 | FromDiscord | <Waldecir Santos> Is it possible to use a macro as a "type", e.g: |
09:40:07 | FromDiscord | <Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P7f |
09:40:23 | FromDiscord | <Elegantbeef> Yes you can use macro/templates as a type annotation |
09:42:04 | FromDiscord | <Waldecir Santos> Hmm do you have one example ? I tried and got this |
09:42:05 | FromDiscord | <Waldecir Santos> https://media.discordapp.net/attachments/371759389889003532/940905385466949642/unknown.png |
09:42:21 | FromDiscord | <planetis> guys should I add usemalloc in the benchmarks\: https://github.com/hanabi1224/Programming-Language-Benchmarks/pull/245 ? |
09:42:25 | FromDiscord | <Waldecir Santos> or do I need to return a `nk?????` that represents a string ? |
09:42:47 | FromDiscord | <planetis> you need to return untyped |
09:43:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3P7g |
09:43:42 | FromDiscord | <demotomohiro> `name; myType()` doesn't work? |
09:44:02 | FromDiscord | <demotomohiro> `name: myType()` |
09:44:10 | FromDiscord | <Waldecir Santos> sent a code paste, see https://play.nim-lang.org/#ix=3P7h |
09:44:17 | FromDiscord | <Waldecir Santos> https://media.discordapp.net/attachments/371759389889003532/940905938783703050/unknown.png |
09:45:01 | FromDiscord | <Elegantbeef> You didnt invoke it |
09:45:07 | FromDiscord | <Elegantbeef> `name: myType()` |
09:45:19 | FromDiscord | <Waldecir Santos> Oh right, thank you |
09:48:00 | FromDiscord | <Elegantbeef> May i ask what you hope the macro to do? |
09:50:49 | FromDiscord | <Elegantbeef> I know it's in relation to your problem yesterday, just curious |
09:52:04 | FromDiscord | <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:12 | FromDiscord | <Waldecir Santos> But tbh my main goal is to learn Nim. |
09:53:27 | FromDiscord | <Elegantbeef> Well jumping into macros headfirst is one way to learn it 😀 |
09:54:15 | PMunch | Is there an easy way to get the name of the current module? |
09:55:31 | FromDiscord | <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:40 | PMunch | Well that's annoying.. |
09:57:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/Yzs |
09:59:24 | PMunch | I mean you can sorta get it from instantiationInfo |
10:21:20 | * | Vladar quit (Quit: Leaving) |
10:23:20 | FromDiscord | <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:58 | PMunch | Yeah inspecting the whole type hierarchy is a bit tricky |
10:27:56 | FromDiscord | <Elegantbeef> Really we need an expanded macros module that has all that stuff |
10:30:50 | FromDiscord | <Elegantbeef> Need a `micros` module which makes your macros smaller 😛 |
10:31:18 | FromDiscord | <vindaar> sent a long message, see http://ix.io/3P7u |
10:32:02 | FromDiscord | <Elegantbeef> disruptek's assume handles that all with options |
10:32:23 | FromDiscord | <vindaar> have a link? |
10:32:28 | FromDiscord | <Elegantbeef> https://github.com/disruptek/assume/blob/master/assume/typeit.nim#L5-L12 |
10:32:59 | FromDiscord | <Elegantbeef> This isnt identical this is about the fields, but the same thing can be used for your above logic |
10:33:32 | FromDiscord | <vindaar> yeah, something like that is probably the right approach |
10:33:57 | FromDiscord | <Elegantbeef> I mean it's just one part of the thing that makes sense |
10:34:58 | FromDiscord | <Elegantbeef> more named things like `returnType` or an `parameters` which yields `(name, type, default)` |
10:35:54 | FromDiscord | <vindaar> yep, that would also be very helpful |
10:36:14 | FromDiscord | <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:33 | FromDiscord | <Elegantbeef> Yea |
10:36:51 | FromDiscord | <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:24 | FromDiscord | <Elegantbeef> Yea being a compiler dev isnt fun 😛 |
10:39:22 | FromDiscord | <Elegantbeef> Ideally you replace most indexing with properties but that's hellish 😀 |
10:39:47 | FromDiscord | <vindaar> properties in what sense? |
10:40:06 | FromDiscord | <Elegantbeef> `myProcDef.body = newStmtList()` |
10:40:32 | FromDiscord | <Elegantbeef> `myIdentDef.typ` |
10:40:34 | FromDiscord | <vindaar> ah, ok |
10:41:16 | FromDiscord | <Elegantbeef> I'm kinda partial to converting common NimNodes into distinct types and work with them that way |
10:41:53 | FromDiscord | <Elegantbeef> The fact all the Nimnodes are exposed to everyone as just an undescript box is absurd imo |
10:42:44 | FromDiscord | <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:38 | FromDiscord | <Elegantbeef> Anyway i'm off, i dont need to talk about this more and encourage myself to do something else |
10:43:49 | FromDiscord | <Elegantbeef> Though i mean i havent touched my game in a few days so clearly that's not working 😀 |
10:43:49 | FromDiscord | <vindaar> haha, fair enough |
10:59:36 | PMunch | Okay, I got a bit carried away: https://github.com/PMunch/superlog |
11:04:17 | FromDiscord | <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:12 | PMunch | @MrOkram, yes, it's just a matter of listening to the correct IP |
12:22:29 | NimEventer | New 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:58 | FromDiscord | <Rika> In reply to @PMunch "Okay, I got a": Nice |
13:10:16 | PMunch | It's a pretty neat concept |
13:11:50 | PMunch | But 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:40 | FromDiscord | <Rika> maybe it should be easy to filter modules |
13:13:48 | PMunch | Filter modules? |
13:14:01 | FromDiscord | <Rika> easier since you already can distinguish by instinfo |
13:14:57 | PMunch | Oh 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:19 | PMunch | But getting the currently executing module is surprisingly cumbersome |
13:15:30 | FromDiscord | <Rika> Ah, loggers are per loggable type |
13:15:38 | FromDiscord | <Rika> thats kinda crazy |
13:16:31 | FromDiscord | <Rika> maybe you should implement/encourage the usage of some common loggable types |
13:16:36 | PMunch | You 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:34 | PMunch | Yeah 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:11 | PMunch | I guess it could be a LogMessage[T: static[string]](msg: string, module: T) though |
13:18:32 | PMunch | With a nice constructor that grabs the current module |
13:19:05 | PMunch | The current implementation doesn't support registerLogger(someType[Generic]) though |
13:20:18 | PMunch | The activeLoggers table should really map from signatureHash to code instead of a string that I manually build from the module |
13:21:59 | PMunch | But then it might be hard to support registering all the versions of a generic type.. |
13:25:16 | PMunch | Oh no, that should be fine, I think |
13:29:30 | PMunch | Yeah, 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:42 | PMunch | In fact it would already work if you just made a type alias for your specific version of the generic |
13:58:57 | NimEventer | New thread by Mardiyah: To insert regex pattern into another, see https://forum.nim-lang.org/t/8886 |
14:01:58 | PMunch | @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:00 | PMunch | So 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:03 | PMunch | Added 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:38 | FromDiscord | <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:25 | PMunch | Haha, sorry for the monologue. I just start thinking about this and my mind fires on all cylinders :P |
14:23:37 | FromDiscord | <Rika> i mean thats good innit |
14:23:55 | FromDiscord | <Rika> i currently understood nothing and i dont know why, i should have |
14:24:10 | FromDiscord | <Rika> i also have one hell of a headache so i should probably go back sleep |
14:24:11 | FromDiscord | <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:18 | PMunch | Damn it, I can't get the symbol for a module without triggering an import.. |
14:59:30 | PMunch | I 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:30 | PMunch | the log statements to empty ones since I haven't registered a logger yet). |
15:02:18 | FromDiscord | <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:09 | NimEventer | New thread by Miran: Nim 1.6.4 released, see https://forum.nim-lang.org/t/8887 |
16:16:37 | FromDiscord | <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:37 | NimEventer | New post on r/nim by miran1: Nim 1.6.4 released, see https://reddit.com/r/nim/comments/soinu5/nim_164_released/ |
17:29:48 | FromDiscord | <untoreh> sent a code paste, see https://play.nim-lang.org/#ix=3P9u |
17:30:36 | FromDiscord | <untoreh> do I have to hash `w` ? |
17:33:40 | FromDiscord | <Rika> its because you're selectively importing |
17:33:58 | FromDiscord | <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:00 | FromDiscord | <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:13 | FromDiscord | <Rika> how do you measure the time |
18:32:03 | FromDiscord | <Rika> going from python to nim to python has overhead |
18:33:00 | * | Nuc1eoN joined #nim |
18:36:07 | arkanoid | is 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:18 | FromDiscord | <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:35 | FromDiscord | <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:28 | Amun-Ra | I 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:56 | FromDiscord | <Waldecir Santos> Yeah I tried but there is a `StrLit` and not sure how to adapt to my scenario |
20:52:08 | Amun-Ra | I guess, the macro wizard (aka Elegantbeef) is asleep :> |
21:07:08 | FromDiscord | <kevin> Is there a good method to convert a `cstring` into a `string` if I know how long the `cstring` is? |
21:07:22 | FromDiscord | <kevin> My `cstring` may or may not have null bytes in it :/ |
21:07:39 | Amun-Ra | kevin: $foo |
21:07:53 | FromDiscord | <kevin> Cuts off on null bytes in the string unforunately |
21:08:03 | FromDiscord | <kevin> so only up until the first null byte |
21:08:11 | Amun-Ra | ah |
21:10:03 | Amun-Ra | I guess newStringOfCap + .add |
21:14:42 | FromDiscord | <vindaar> @Waldecir Santos\: can you clarify what it is you're trying to do? |
21:15:00 | FromDiscord | <vindaar> normally it should be enough to just return an ident of the type you want |
21:15:25 | FromDiscord | <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:05 | FromDiscord | <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:35 | FromDiscord | <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:54 | FromDiscord | <ckennedy> If I dereference things at the `seq.add` call site it seems work; `things[].add(...)` instead. |
22:00:43 | FromDiscord | <Elegantbeef> You're dereferencing the ref and storing it in a copy |
22:01:12 | FromDiscord | <Elegantbeef> `var a = somRef[]` makes `a` a non reference value type |
22:01:17 | FromDiscord | <Elegantbeef> @ckennedy\: ^ |
22:01:58 | FromDiscord | <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:41 | FromDiscord | <Elegantbeef> There you go |
22:02:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3PaE |
22:03:18 | FromDiscord | <Elegantbeef> you can also do `return bindSym $mType` i believe |
22:03:19 | FromDiscord | <Waldecir Santos> oh I thought bindSym was meant to bind functions |
22:03:39 | FromDiscord | <Elegantbeef> `bindSym` can bind any symbol on the scope of the macro |
22:03:59 | FromDiscord | <Waldecir Santos> Nice, thank you ! |
22:04:54 | FromDiscord | <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:26 | FromDiscord | <Elegantbeef> `[]` is to be expected, but you can always make your own `.add` it |
22:06:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3PaF |
22:07:59 | FromDiscord | <Elegantbeef> There is an experimental auto dereference but i'll be deprecated in afaik |
22:08:00 | FromDiscord | <vindaar> @Waldecir Santos, [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org) but you don't even need `bindSym` here |
22:08:01 | FromDiscord | <ynfle> In reply to @ckennedy "So if I'm working": You shouldn't need to deref, it automatically derefs for field accesing |
22:08:12 | FromDiscord | <Elegantbeef> `add` isnt a field |
22:08:43 | FromDiscord | <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:58 | FromDiscord | <Waldecir Santos> In reply to @vindaar "<@121971538898452482>, [Elegantbeef](https://matrix": not sure what you mean |
22:09:02 | FromDiscord | <Elegantbeef> I showed them an example with an ident and they apparently didnt want to use it 😛 |
22:09:08 | FromDiscord | <Elegantbeef> you can do `ident"MyType"` |
22:09:27 | FromDiscord | <vindaar> Ah, missed that 😁 |
22:09:27 | FromDiscord | <Elegantbeef> I guess you can do `return MyType.getType`? |
22:09:28 | FromDiscord | <Waldecir Santos> It didn't worked @@ let me try again |
22:09:40 | FromDiscord | <Waldecir Santos> bindSym worked |
22:09:50 | FromDiscord | <Elegantbeef> It will not work if the `MyType` is not exported |
22:09:58 | FromDiscord | <Elegantbeef> If `MyType` isnt exported then you need bindsym |
22:10:31 | FromDiscord | <Waldecir Santos> well ident is working now too, shame on me |
22:10:47 | FromDiscord | <Elegantbeef> Well if you move them to different modules it'll fail, so take that into account |
22:10:53 | FromDiscord | <Waldecir Santos> What is the diferente between `ident` and `bindSym`. 🤔 |
22:11:06 | FromDiscord | <Elegantbeef> `ident` is an untyped identifier |
22:11:27 | FromDiscord | <Elegantbeef> `bindSym` finds the symbol in the scope of the macro and grabs it, holding onto a typed identifier |
22:13:35 | FromDiscord | <Waldecir Santos> Thank you ! |
22:46:28 | FromDiscord | <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:04 | FromDiscord | <Elegantbeef> `macro foo(x: typed): untyped =` |
22:48:56 | FromDiscord | <amadan> Epic, thanks for that↵Always thought macros returned untyped by default |
23:17:46 | FromDiscord | <rainbowasteroids> What is the difference between `Exception` and `CatchableError`? |
23:22:21 | * | rockcavera quit (Remote host closed the connection) |
23:27:14 | FromDiscord | <konsumlamm> an `Exception` is not necessarily catchable |
23:31:02 | FromDiscord | <Elegantbeef> Exceptions are catchable are they not? |
23:31:14 | FromDiscord | <Elegantbeef> Ah nvm |
23:31:36 | FromDiscord | <Elegantbeef> Exception is the base type that Defect and CatchableError come form |
23:31:58 | FromDiscord | <Elegantbeef> Defects are not to be caught and signify a programmer error, CatchableErrors are safe to catche |
23:33:37 | FromDiscord | <rainbowasteroids> So, does `except` not work on objects that don't inherit from `CatchableError`? |
23:33:58 | FromDiscord | <Elegantbeef> Right |
23:34:14 | FromDiscord | <Elegantbeef> Well `except` works for `Defect` but only in some dialects |
23:34:17 | FromDiscord | <Elegantbeef> Which is why you dont use it for them |
23:34:26 | FromDiscord | <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:46 | FromDiscord | <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 |