newProc macro question

2024-01-05 Thread ratchet
Type inference is already wonky for the most part without even defining my own macros so that's not an issue for me. But I'll keep that in mind.

newProc macro question

2024-01-04 Thread sls1005
It makes your example to work. But you'll also lose the ability of getting the type information from the input, by using an `untyped` parameter. Another way is to take a typed parameter and make a recursive copy of it, replacing every node of the kind of `nnkSym` with that of `nnkIdent`. But I

newProc macro question

2024-01-04 Thread ratchet
Is that seriously all I had to do... thanks guys.

newProc macro question

2024-01-04 Thread Isofruit
For ratchet on what that does: It tells nim to not really try to make sense of whatever code gets put into the `mkCaster` macro. So you are allowed to have entirely invalid stuff in there, you just need to create NimNodes that contains valid code as the macro output (which you do). By using pr

newProc macro question

2024-01-04 Thread sls1005
Replacing `proc` with `untyped` will fix it. macro mkCaster(caster: untyped) Run It seems that all the symbols were bound to somewhere before passed into the macro, as a side effect of using typed parameter. The compile thus thought you were capturing outter variables

newProc macro question

2024-01-04 Thread ratchet
Hey, I'm trying to implement a macro to reduce some cumbersome boilerplate code. However, I can't seem to get `newProc` to work. Here's the stripped down macro code: import std/macros macro mkCaster(caster: proc) = expectKind(caster, nnkLambda) echo