Hey folks!
As the immediate pragma is deprecated, I'm updating my packages to remove references to it. I've got one situation where I'm curious about the best alternative. It's this template. Basically, I'm using a template to define a type with a few procs. When I remove {. immediate .}, my test fails.
I know I could achieve this using a macro instead, but since all I'm doing is some basic substitutions, a template feeks a bit more clear. What's the best way to achieve this?
Try this prototype:
template defineIndex*(name, source, extractIt, cmpAB: untyped) = ...
Yup, that works.
For anyone looking to spot the difference, here is original signature:
template defineIndex*(name, source: typedesc, extractIt, cmpAB: untyped) {.immediate.} = ...
When you just remove the immediate, it breaks. Here is the working signature:
template defineIndex*(name, source, extractIt, cmpAB: untyped) = ...
The difference is that _all of the arguments are untyped, versus using typedesc for the first two arguments.
@Araq, if you've got a moment (or anyone else that can offer details): why does this work?