Primitive Queue<any T> considerations

Vitaly Davidovich vitalyd at gmail.com
Wed Nov 18 19:30:36 UTC 2015


Although I agree that sometimes a sentinel or even an entire range of
values is available to indicate absence, I don't think it's the right
answer to the question.  In particular, if you're writing a general purpose
collection, you cannot expect your users to remove one possible value from
their universe to signal absence.  The collections that do this today are
simply working around lack of nullable primitives.

On Wed, Nov 18, 2015 at 2:18 PM, Richard Warburton <
richard.warburton at gmail.com> wrote:

> Hi,
>
> I'm not sure about the default null-indicator because every time a queue is
> > needed in our library, that can serve a source with unique choice of a
> > default-null value. It is unlikely the users of the library want or can
> > specify that all the time.
> >
>
> I appreciate that this is diverging directly form your language related
> question, but it is pertinent to writing anyfied collections using
> Valhalla. My experience using primitive specialised collections is that it
> has always been possible to have a sentinel value, though obviously my
> experience won't necessary reflect that of every single person in the Java
> community. It isn't always appropriate for it to be 0, which is what I
> think T.default is currently going to return for primitives and when I've
> done primitive specialised collections before they allow you to specify the
> missing value sentinel.
>
> Have you got of an actual genuine use case where a sentinel value doesn't
> work well, rather than a theoretical "hey, maybe you want to have a set
> that contains every possible int?"
>
> regards,
>
>   Richard Warburton
>
>   http://insightfullogic.com
>   @RichardWarburto <http://twitter.com/richardwarburto>
>


More information about the valhalla-dev mailing list