> You are not supposed to use not nil types as Option generic parameters

Then how do I make a function that conditionally returns a value of that type, 
like the `makeFoo` function in my example? "Option(al)" is the canonical way to 
do this in other languages. I could use a regular ref as the parameter, like 
`Option[ref FooObj]`, but then the value I extract from such an Option can't be 
assigned to a regular Foo since the compiler doesn't realize it can't be nil...

I can understand why the current implementation of the `Option` class might 
have trouble with a not-nil type, since the pointer it stores internally needs 
to support nil. That seems more like a bug/limitation of `Option`.

Sorry to hear that `not nil` is less capable than it looks (it really should be 
moved out of the main compiler docs), but I'm glad there's some recent design 
work going on. IMHO this is one of the weak corners of Nim as compared with 
other modern languages like Rust and Swift.

Reply via email to