Macros
macro caster(def): untyped
-
a sugar for casting parameters in the procedure body, It eliminates the need for manually casting.
for an illustration, the 2 procedures are the same:
Example:
proc toNumericRepr1(c: char): string = let b = cast[byte](c) $b proc toNumericRepr2(b: char as byte): string {.caster.} = $b assert "97" == toNumericRepr1 'a' assert "97" == toNumericRepr2 'a'