Hello everyone!
I am developing some DSLs using nim's macro system, and I would like to
implement my own function syntax. My aim is to have the syntax to look quite
similarly to Python's `def`
([https://docs.python.org/3/library/typing.html)](https://docs.python.org/3/library/typing.html\)).
However, I can't seem to get the function signature to even enter the macro's
parsing. Consider this:
macro my_func(func_signature : untyped, func_body : untyped) =
echo "Macro logic here..."
my_func something(a : float = 0.5) -> float:
return a + 0.5
Run
This would return this error:
Error: expected: ')', but got: '='
Run
While, on the other hand, by simply removing the `:` in `a : float = 0.5`, or
by using any other symbol in its place (like `$`), the code would correctly
enter the macro block:
macro my_func(func_signature : untyped, func_body : untyped) =
echo "Macro logic here..."
my_func something(a float = 0.5) -> float:
return a + 0.5
my_func something(a $ float = 0.5) -> float:
return a + 0.5
Run
Is there something I'm missing here? Why isn't the `a : float = 0.5` construct
supported? Shouldn't it be the same as how `proc`'s function signature is
working?