I want to implement a class with a property whose type I can change globally at compile time. For example,
let ID_TYPE = Int
@value
struct MyStruct:
var a: ID_TYPE
However, let
seems not to be applicable to define types, as I receive the error invalid call to '__del__': argument #0 cannot be converted from 'Int' to 'Int'mojo
What can I do to avoid having to manually change all places where the ID_TYPE
occurs in my code when I change e.g. from Int
to Uint8
?
Compile-time variables can be set via the alias
keyword. Then, the example reads as follows:
alias ID_TYPE = Int
@value
struct MyStruct:
var a: ID_TYPE