type foo = string
proc bar(s: string): int =
return 10
proc bar(s: foo): int = # Error: redefinition of 'bar'
return 15
var s: foo = "123"
echo s.bar
Is there any way to work this around? Answer to "why?" is simple: it would be useful if we could have our own string types. For example utf8-aware string.
#Add distinct http://nim-lang.org/docs/manual.html#types-distinct-type
type foo = distinct string
proc bar(s: string): int = 10
proc bar(s: foo): int = 15
var s = foo "123" #Or "123".foo
echo s.bar