proposed @noreturn attribute

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 9 17:34:54 PDT 2017


On 07/09/2017 07:34 PM, Meta wrote:
> On Sunday, 9 July 2017 at 22:28:50 UTC, Andrei Alexandrescu wrote:
>> On 07/09/2017 03:12 PM, Walter Bright wrote:
>>> On 7/9/2017 6:13 AM, Andrei Alexandrescu wrote:
>>>> We should use typeof(assert(0)) for Bottom. There is precedent - 
>>>> there is no name for typeof(null).
>>> I had forgotten about the typeof(null) thing. You're right. But there 
>>> are some issues. What do we do with:
>>>
>>>      typeof(assert(0))* p;
>>>
>>> ? What does that mean?
>>
>> That would be a pointer that may only be null - a consequence of the 
>> typeof(assert(0)) being uninstantiable.
>>
>> Generally I'm not too worried about constructs like 
>> typeof(assert(0))[], typeof(assert(0))*, use in templates etc - we 
>> don't need to "design" these cases, their behavior flows from the 
>> properties of typeof(assert(0)) itself.
>>
>> Similarly, I don't recall ever there being a problem with 
>> typeof(null)*, typeof(null)[], people complaining they passed 
>> typeof(null) to a template where it did bad things, etc.
>>
>>
>> Andrei
> 
> `typeof(null)` actually has one valid value and doesn't crash the 
> program when when you try to create an instance of it. We should not 
> treat this the same as `typeof(null)`.

Agreed (with the mention it's not in contradiction with the above). -- 
Andrei


More information about the Digitalmars-d mailing list