bottom type as parameter or local variable, does that make sense?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Jan 18 18:02:19 UTC 2022


On Tue, Jan 18, 2022 at 12:55:06AM +0100, Timon Gehr via Digitalmars-d wrote:
> On 17.01.22 20:39, H. S. Teoh wrote:
> > Making variables of type noreturn illegal
> 
> Variables of type `noreturn` should certainly remain legal, perhaps
> just not default initialization of such variables.
> 
> > does not preclude taking parameters of type noreturn
> 
> Sometimes it would, but it should not. E.g., this is fine:
> 
> noreturn foo(noreturn x){
>     auto y=x;
>     return y;
> }

Hmm. This again treads that default-initialization / manual
initialization fine line.  I can see why such a thing would be useful
(e.g., you pass a throwing (i.e., noreturn) predicate to a range
function and expect that it should still compile and run), but having to
special-case it seems to go against the entire point of having a
noreturn type.

Now I'm also lost as to what the "right" behaviour ought to be. :-D


T

-- 
They pretend to pay us, and we pretend to work. -- Russian saying


More information about the Digitalmars-d mailing list