afaik there's nothing technical preventing overloading by return type. However
one trick I use is to simply add a typedesc parameter and overload on that. So
instead of var s: string = somefunction(d) I'd just say var s = somefunction(d,
string) Hell since you already have the converter you
I'm interested in the specs of the machine these benchmarks were run on. The
CPU architecture can have a huge impact on this kind of thing.
**@erikenglund**: Perhaps you would be willing to do a full write-up for this
proposal? Something as significant as changing the default `int` size of a
Unsure what I should be doing differently in the following code as to prevent
the warnings:
import strutils
type MouseButton* = enum
mbLeft = 1
mbMiddle = 2
mbRight = 3
let s = "mbLeft"
let m = parseEnum[MouseButton](s)
echo m
Good! And several other replies here point out good things too - especially the
fact that * can export a type but members are still hidden unless explicitly
exported etc. Yeah, Smalltalk is a beauty. At the moment I don't hack much
Smalltalk but I am hoping for [Spry](http://sprylang.org) to
You don't export what you don't want to export. You cannot export what you
don't mark it with `*`.
You can export the `pBox` but don't export the implementation `BoxOfStuff` and
Nim still happily checks whether the type is consistent or not.
Also you can limit imported symbol using from module
I never understood why Nim doesn't allow this.
If you want to keep the same name and use overloading, one option is to use a
_var_ argument instead of return. This works:
proc myBirthday(n: var int) =
n = 372297600
proc myBirthday(s: var string) =
s = "October
I was looking at the COM module of Winim and came across what looks to be (to
my newbie eye) procedure overloading by return type:
converter variantConverter*(x: variant): string = fromVariant[string](x)
converter variantConverter*(x: variant): cstring = fromVariant[cstring](x)