exit() to end a function

spir denis.spir at gmail.com
Mon Feb 14 06:24:00 PST 2011


On 02/14/2011 03:12 PM, Steven Schveighoffer wrote:
> On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
>
>> There would be some value to having an attribute which indicated that a function
>> never returns under any circumstances (likely since it always throws), but that
>> wouldn't help exit any, since it's a C function and wouldn't have the attribute.
>
> The bindings to C can be attributed as we see fit. A C symbol is not mangled,
> and so you can attach any attributes you want (you can even change the number
> and types of parameters).
>
>> Regardless, I see little value in complicating dmd even a little bit more just
>> so that you don't have to insert an extra assert(0) after exit - particularly
>> when very few programs call exit, and very few should.
>
> I agree with this.
>
>> Generally, something is
>> horrendously wrong if exit is being called, and there's probably a better way to
>> handle it.
>
> I don't agree with this, exit has its valid uses.

Agree with Steven. All my modules hold:

import core.stdc.stdlib : exit;
// debug tool func
void stop () { exit(0); }

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list