Not sure what you mean by needing a dummy value if your function only returns success/failure. That's what a boring old error return is for.
func foo() error
Re:Option and null in dynamic languages
by stormbrew on Tuesday December 09, 2014 @04:42PM
(#8725991)
Yes, but unlike having a second result this particular error check need not be touched. To make it so the caller has to check it, I'd have to return a dummy normal return.
Re:Option and null in dynamic languages
by NateDad on Wednesday December 10, 2014 @03:24PM
(#8731451)
You can always call a function and not assign the return calls to anything.
If you have
func foo() (string, error)
You can still call it thusly:
foo()
However there are tools to check for unchecked errors like this one: https://github.com/kisielk/errcheck
Meanwhile, the actual concept of option type has been around for ages and could have been used instead of trying to twist MRV into it.
Thankfully, all the other newer languages are doing the right thing imo.