A disclaimer or two for Optional
tim at peierls.net
Wed Oct 23 07:29:05 PDT 2013
On Wed, Oct 23, 2013 at 9:48 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> Comparing an Optional with null would be pretty funny. For other
> potential value types, such as Boolean and Integer, comparing with null
>> is, unfortunately, a somewhat common idiom: null means "not assigned".
> Right. My take is that the existing primitive wrapper types are
> hopelessly polluted and must always mean "boxed primitives". But, for
> new-in-8 classes (Optional, and the 310 date-time classes), there may be
By "there may be hope", you mean there may be hope of reducing misuse --
as-if-full-reference-type use -- of these new-in-8 valueish types while
they are not yet full value types by adding class-specific disclaimers?
If so, Optional is probably the least appropriate candidate for such
special pleading. Since avoidance of null is a big motivation for Optional
in the first place, you're far less likely to find folks doing comparison
to null (or other Rose no-nos) with Optional than with any other
valueish-type you can think of. Users of Optional have already got the
religion; no need to preach to the choir.
I think a better way to prepare folks for such a language change would be
to create a separate section in an overview or package doc that describes
valueish types and what you shouldn't do with them, perhaps mentioning the
possibility of a language change that would make such misuse entirely
broken, and add links from the class comment for all such types to this
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lambda-libs-spec-experts