exit() to end a function

Jonathan M Davis jmdavisProg at gmx.com
Mon Feb 14 08:19:24 PST 2011


On Monday 14 February 2011 06:12:56 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.

Well, I agree that it has its valid uses, but I think that such uses are quite 
rare. You shouldn't normally be writing programs that choose to essentially just 
die in the middle of their execution.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list