proposed @noreturn attribute
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 11 01:38:52 PDT 2017
On 10.07.2017 04:44, Walter Bright wrote:
> Let's call the bottom type 'B' for the moment, for convenience.
>
> If we think of it like a floating point NaN,
It's not. It's an empty type.
> then any type construction
> of B yields a B:
>
> const(B) -> B
I don't see why to add this special case.
> B* -> B
> B[] -> B
> X[B] -> B
> B[X] -> B
> ...
This would be wrong. All of the types on the left have valid values,
they are not isomorphic to B.
> Since B cannot have a value, any expression that forms a B can be
> replaced with an assert(0).
>
> B foo(); // declaration
> foo() -> foo(); assert(0);
>
Yes.
> cast(B)exp -> exp; assert(0);
>
> B b; -> assert(0);
>
Those wouldn't compile. (Nothing can be cast to bottom, there is no
default initializer that the variable declaration can use.)
> Given a tuple of types:
>
> alias T = tuple(B,X);
>
> is T equivalent to which of:
>
> B (1)
> tuple(X) (2)
> tuple(Y,X) (3)
> tuple(B,X) (4)
>
> ? I'm leaning toward (4) as making the most sense.
> ...
It's the only one that makes any sense.
> struct S {
> T t;
> }
>
> should then yield an error, while:
>
> struct S {
> T[1..1] t; // t is of type X
> }
>
> would not.
I guess you meant T[1..2].
More information about the Digitalmars-d
mailing list