Bottom Type--Type Theory
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jan 18 01:33:00 UTC 2019
On Fri, Jan 18, 2019 at 01:04:58AM +0000, Q. Schroll via Digitalmars-d wrote:
> On Thursday, 17 January 2019 at 22:13:13 UTC, H. S. Teoh wrote:
> > [...]
> > This also lets us write sanity-checking expressions such as:
> >
> > float sqrt(float x) {
> > return (x >= 0.0) ? ... /* implementation here */
> > : Bottom.init;
> > }
> >
> > This is valid since Bottom converts to any type. Then at runtime, if
> > x < 0.0, assert(0) gets triggered.
>
> While unrelated to the DIP discussion, I will insist that x >= 0.0 and
> x < 0.0 can both be wrong: x can be NaN.
`NaN >= 0.0` evaluates to false, so the assert will still trigger.
T
--
English is useful because it is a mess. Since English is a mess, it maps well onto the problem space, which is also a mess, which we call reality. Similarly, Perl was designed to be a mess, though in the nicest of all possible ways. -- Larry Wall
More information about the Digitalmars-d
mailing list