Macro beginner code review

2021-02-05 Thread Psirus
Yes, `cfunc` is in reality a C function from an external library that I want to wrap that does something completely different.

Macro beginner code review

2021-02-04 Thread Psirus
So I'm trying to learn macros, and its not easy if you've never done metaprogramming. Anyway, I'm trying to write a wrapper for a C function that takes a variable number of arguments, with the first being a string that specifies the types of the rest. I want the wrapper to create this string au

Compile-time members

2020-10-27 Thread Psirus
So I'm still trying to wrap my head around compile-time computing and templates in Nim, but am struggling mightily. Anyway, I wanted to construct types based on other types (generic types?), but with members of the parameter type as parameters in the type definition. An example that doesn't com

Compile-time if and/or syntax conflicts

2020-10-27 Thread Psirus
So I'm relatively new to nim, and have been using generics to great effects. Really enjoying the experience so far. Now I wanted to do something different depending on the type parameter, like this: proc createMyArray*(N: static[int]): array[N, int] = if N == 2: resul