Sentinels in collections, was RE: Primitive Queue<any T> considerations

Rezaei, Mohammad A. Mohammad.Rezaei at
Thu Nov 19 01:15:26 UTC 2015

Richard asked for examples of collections that had to have sentinels and I provided some, but realizing that these are internal ones, changed the subject.

From a Valhalla perspective, the fact that one cannot manufacture a sentinel besides T.default is a real problem for collections that need more than one sentinel. The current types (primitives, references) don’t have this limitation. (This is also not a problem in languages like C where I can cast a struct to char* and fill it with arbitrary bit patterns).


From: Vitaly Davidovich [mailto:vitalyd at]
Sent: Wednesday, November 18, 2015 6:32 PM
To: Richard Warburton
Cc: valhalla-dev at; Rezaei, Mohammad A. [Tech]
Subject: Re: Sentinels in collections, was RE: Primitive Queue<any T> considerations

I'm still unclear on how we ended up discussing internal sentinels that are effectively implementation details.  I don't think there's any debate on this part.

I do, however, disagree on sentinels that leak out of the implementation and require user to select a magic number.  And I say this as someone who constantly exploits domain specific constraints on values to optimize code.  In particular, in a world where optional<value_type> is cheap asking user to declare a magic number is unfortunate; this is required today, but it's a language limitation.  I'd hate to have that perpetuated once better language features are available.

sent from my phone
On Nov 18, 2015 6:19 PM, "Richard Warburton" <richard.warburton at<mailto:richard.warburton at>> wrote:

Agreed, so maybe I misinterpreted Richard’s email (I tried to mitigate by changing the subject). Richard, which type of sentinel did you mean?

Well I was originally thinking in terms of the Queue interface itself, which needed a sentinel taken out of the user's domain. I don't think its a problem to expand the discussion though and you're certainly right to observe that there are two different kinds of sentinel.

  Richard Warburton

More information about the valhalla-dev mailing list