-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
36 activations of term rewriting macro? #9288
Comments
To add to the complication, if I add another multiplication after that first one, the TRM stops activating altogether: template mulIsCommutative{`*`(a, b)}(a, b: int): int =
debugEcho("-> Term rewriting activated!")
b * a
let x = 3
echo "Calculating x * 2:"
echo x * 2
echo ""
echo "Calculating x * 2 again:"
echo x * 2
echo ""
echo "Calculating x * 3:"
echo x * 3 Output:
|
The confusion stems from the fact that term rewriting macros are applied recursively (up to a limit). I think this should be documented in the manual and all 3 issues closed |
That limit is 36?
I can understand that for the first multiplication overflow happened, and TRM stopped activating after 36 loops. But then why does it not get activated at all for the next 2 multiplications? Once the limit is reached, the TRM stops working altogether for the rest of the program? |
I presume so, according to your experiments |
It would be more ensuring to get a better answer. "presume so" sounds like you also don't know for sure if that's the case. I'd like to know the answers to my 3 questions based on spec or design choice rather than based on my toy example. |
I took an example from the Nim Manual's TRM section: https://nim-lang.org/docs/manual.html#term-rewriting-macros
The example is almost as-is except that I added a
debugEcho
so that I know if/when the TRM is getting activated:Surprisingly that prints:
Ref: https://gitter.im/nim-lang/Nim?at=5bbe2eb6bbdc0b25051a4d02
/cc @Araq
The text was updated successfully, but these errors were encountered: