To combine what @def and @Udiknedormin have suggested:
import options
converter toOption[T](x:T):Option[T] = some(x)
proc xxx(param1: string, param2, param3 = none(int)) =
if param2.isSome:
echo "param2: ", param2.some
if param3.isSome:
echo "param3: ", param3.some
xxx("a", param2 = 1)
xxx("b", param3 = 2)
xxx("c", 3, 4)
xxx("d")
Run
I'm curious if there are downsides to having that `toOption` converter hanging
around. I can't think of any downsides. I'm curious if it would be worth having
that converter included in the std lib. Thoughts?