macro definestruct(name, ndims)
return quote
struct $name{T}
v::Vector{T}
end
$name(v::Vector{T}) where T = $name{T}(v)
nvars(::$name) = $ndims
end
end
@definestruct(MyStruct, 6)
produces the following error:
ERROR: ArgumentError: invalid type for argument number 1 in method definition for #39#nvars at /Users/olly/.julia/dev/scratch/macro.jl:7
If I comment out the line above the nvars definition, it goes away. I don’t really understand why the error is happening. Can anyone explain?