The closes solution is probably this:
immutable IntParam{N}
IntParam() = isa(N, Int) ? new() : error("Non integer argument for N: $(N)")
end
IntParam(N) = IntParam{N}()
IntParam{1}() #-> works
IntParam(1) #-> works
IntParam{:test}() #-> error
IntParam(:test) #-> error
Am Mittwoch, 20. Mai 2015 23:28:26 UTC+2 schrieb Josh Langsfeld:
>
> I want to implement some functionality in multiple methods and have the
> dispatch controlled by an Int variable "N". The trick is I want one method
> to be called if N == 0 and another one to be called for all other values of
> N. Is there a way I can do this with "Val{N}" without making the method
> applicable to everything? That is, can I write a generic method
> "func(::Val{N}) and constrain N to be an Int only?
>