Spec#, nullables and more

Denis Koroskin 2korden at gmail.com
Sun Nov 7 01:42:56 PST 2010


On Sun, 07 Nov 2010 00:58:57 +0300, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> FeepingCreature wrote:
>> Walter Bright Wrote:
>>
>>> FeepingCreature wrote:
>>>> Walter Bright Wrote:
>>>>> All that does is reinvent the null pointer seg fault. The hardware  
>>>>> does
>>>>>  this for you for free.
>>>> Walter, I know you're a Windows programmer but this cannot be the  
>>>> first
>>>> time somebody has told you this - YOU CANNOT RECOVER FROM SEG FAULTS
>>>> UNDER LINUX.
>>>>  Access violations are not a cross-platform substitute for exceptions.
>>> Why would you want to recover from a seg fault?
>>>  (asserts in D are not recoverable exceptions)
>>  You cannot do a lot of things from a signal handler. You can't sjlj,  
>> which
>> means sjlj exception handling is out (as are, in fact, most methods of
>> exception handling). This means stack traces are out unless you have  
>> special
>> handling for segfaults that decodes the stack and prints the error pos.  
>> That
>> in turn means you need to have a debugger attached to get stacktraces,  
>> which
>> can be annoying especially in long-running programs where the crash is  
>> often
>> the first indication you have of a problem.
>>  Furthermore, scope guards will not be run. You can't run the GC from a  
>> signal
>> handler because it requires pthreads which is not safe for signal  
>> handlers.
>> Garbage collected classes will not be freed. Static class destructors  
>> cannot
>> be run. Module destructures can not be safely executed.
>
> Sure. That's why assert errors are not recoverable.
>

And that's why modern languages are designed to *prevent* segfaults from  
happening using non-nullable types.
D has nothing to prevent them, and that's why everyone here is pushing  
this concept so hard.

D has its power in compile-time facilities. Non-nullables will only make  
this power stronger.


More information about the Digitalmars-d mailing list