[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: NULLS, nil value, exceptions, and William Kahan
- From: Mark Hamburg <mhamburg.ml@...>
- Date: Wed, 14 Jan 2015 08:50:55 -0800
Swift optionals are sort-of an implementation of the Maybe-monad.
An alternative to exceptions would be a more general version of NaN which is in itself essentially a form of the Maybe monad. If one doesn't want to introduce a new value, then use nil. nil[ key ] yields nil. Calling nil yields nil. Etc. Or introduce a new error type that can include more information and use this as a result. I'm not sure what should happen in error cases that don't return values such as assignments to entries in values that aren't tables.
> On Jan 11, 2015, at 2:39 AM, Tim Hill <firstname.lastname@example.org> wrote:
> For another interesting approach, see the use of optionals in Swift (which I suspect are not original to Swift, but are reasonably well thought out).