On 2016-10-30 4:11 PM, Darren Duncan wrote:
On 2016-10-30 5:45 AM, yary wrote:
Before/AfterEverything are also easy to understand, and would be as natural to
use for sorting strings, eg. for saying if a database NULL should go before the
empty string or after everything else. On the other hand, if I'doing something
with tangents and handling pi/2, I'd rather be thinking about PosInf as my
exception and not AfterEverything.

So, the main thing that I think should exist is a generic
before/after-everything concept so that it can be used to indicate that generic
intervals are unbounded at either end and that generic 'cmp' etc are
automatically defined for every other type and them and use as identity values
for min/max.

So, following up on this, ...

I went with the singleton names Before_All_Others and After_All_Others in my abstract database protocol API for Perl 6, and explicitly documented that these are a type-agnostic analogy to negative/positive infinity whose sole purpose is to canonically sort before or after every other value in the type system, and they expressly do NOT represent any mathematical or physical concept of infinity, including those in IEEE floating point, which should be defined separately where useful. Example uses of these singletons are to represent the endpoints of partially or totally unbounded intervals/ranges, or be the identity values for "min" and "max", or be the result when one calls "pred" or "succ" on the first/last value of an orderable type.

And so, I also want to propose that Perl 6 add the 2 singletons X::BeforeAllOthers and X::AfterAllOthers for similar type-generic use cases. Yet other singletons or values can exist to meaningfully represent mathematical infinities etc such as the IEEE floats support so appropriate semantics exist in peoples' code.

-- Darren Duncan

Reply via email to