Hi guys,
Learning Nim as a game programming language. Been following along from a distance for a while, but decided to dive in. Really loving it.
I am a bit puzzled by the following behavior:
proc f(x: SomeNumber) = discard
f(1.1) # OK
f(1) # OK
proc g(x: SomeNumber = 1'f64) = discard
g(1.1) # OK
g(1) # Error
Why would the default parameter have any effect on the parameter's type in this case? Is there some technical or design decision that makes this so? Is there some technique or idiomatic way of dealing with this situation?
Note that this is a distillation of basically an entire API where I would ideally be able to supply defaults to many functions with type class parameters.
Thanks, _c
Welcome! I'm glad you chose Nim for games, I've been interested in that possibility as well.
Hmm, I'm curious if @Araq will reply to this. I'm guessing that the second example really takes a float because the default parameter is more specific/derived than Some Number. Honestly I don't know if this is intended ssemantics or a compiler bug. I'll see what others say about it :)