@noreturn property

2010-10-21 Thread Iain Buclaw
A few standard library functions, such as 'abort' and 'exit', cannot return. However there is no way in DMD to let the compiler know about this. Currently in D2, you must either have a 'return' or 'assert(0)' statement at the end of a function body. It would be nice however if you can give hints to

Re: @noreturn property

2010-10-21 Thread Bernard Helyer
> > Thoughts? I really, really like the idea.

Re: @noreturn property

2010-10-21 Thread bearophile
Iain Buclaw: > @noreturn void fatal() > { > print("Error"); > exit(1); > } See also the same feature in GNU C: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bnoreturn_007d-function-attribute-2455 Bye, bearophile

Re: @noreturn property

2010-10-21 Thread Lars T. Kyllingstad
On Thu, 21 Oct 2010 11:54:26 +, Iain Buclaw wrote: > A few standard library functions, such as 'abort' and 'exit', cannot > return. However there is no way in DMD to let the compiler know about > this. Currently in D2, you must either have a 'return' or 'assert(0)' > statement at the end of a

Re: @noreturn property

2010-10-21 Thread Steven Schveighoffer
On Thu, 21 Oct 2010 08:52:35 -0400, Lars T. Kyllingstad wrote: On Thu, 21 Oct 2010 11:54:26 +, Iain Buclaw wrote: A few standard library functions, such as 'abort' and 'exit', cannot return. However there is no way in DMD to let the compiler know about this. Currently in D2, you must ei

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
== Quote from Lars T. Kyllingstad (pub...@kyllingen.nospamnet)'s article > On Thu, 21 Oct 2010 11:54:26 +, Iain Buclaw wrote: > > A few standard library functions, such as 'abort' and 'exit', cannot > > return. However there is no way in DMD to let the compiler know about > > this. Currently in

Re: @noreturn property

2010-10-21 Thread Lars T. Kyllingstad
On Thu, 21 Oct 2010 09:14:01 -0400, Steven Schveighoffer wrote: > On Thu, 21 Oct 2010 08:52:35 -0400, Lars T. Kyllingstad > wrote: > >> On Thu, 21 Oct 2010 11:54:26 +, Iain Buclaw wrote: >> >>> A few standard library functions, such as 'abort' and 'exit', cannot >>> return. However there is

Re: @noreturn property

2010-10-21 Thread Justin Johansson
On 21/10/2010 10:54 PM, Iain Buclaw wrote: A few standard library functions, such as 'abort' and 'exit', cannot return. However there is no way in DMD to let the compiler know about this. Currently in D2, you must either have a 'return' or 'assert(0)' statement at the end of a function body. It w

Re: @noreturn property

2010-10-21 Thread Ezneh
Iain Buclaw Wrote: > > > Thoughts? This can be a great idea. In the same way, I saw something that can be good too about returned values in Nimrod : http://force7.de/nimrod/tut1.html#discard-statement Hope the explanation is sufficient. This way, the programmer knows when he "throws away"

Re: @noreturn property

2010-10-21 Thread Leandro Lucarella
Iain Buclaw, el 21 de octubre a las 11:54 me escribiste: > A few standard library functions, such as 'abort' and 'exit', cannot return. > However there is no way in DMD to let the compiler know about this. > Currently in D2, you must either have a 'return' or 'assert(0)' statement at > the end of a

Re: @noreturn property

2010-10-21 Thread Daniel Gibson
Leandro Lucarella schrieb: Iain Buclaw, el 21 de octubre a las 11:54 me escribiste: A few standard library functions, such as 'abort' and 'exit', cannot return. However there is no way in DMD to let the compiler know about this. Currently in D2, you must either have a 'return' or 'assert(0)' sta

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
== Quote from Leandro Lucarella (l...@llucax.com.ar)'s article > Iain Buclaw, el 21 de octubre a las 11:54 me escribiste: > > A few standard library functions, such as 'abort' and 'exit', cannot return. > > However there is no way in DMD to let the compiler know about this. > > Currently in D2, you

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
== Quote from Daniel Gibson (metalcae...@gmail.com)'s article > Leandro Lucarella schrieb: > > Iain Buclaw, el 21 de octubre a las 11:54 me escribiste: > >> A few standard library functions, such as 'abort' and 'exit', cannot > >> return. > >> However there is no way in DMD to let the compiler kno

Re: @noreturn property

2010-10-21 Thread bearophile
Ezneh: > I saw something that can be good too about returned values in Nimrod : > http://force7.de/nimrod/tut1.html#discard-statement > Hope the explanation is sufficient. This way, the programmer knows when he > "throws away" a returned value. > I think that could be great too. In C-like langu

Re: @noreturn property

2010-10-21 Thread Rainer Deyke
On 10/21/2010 05:54, Iain Buclaw wrote: > @noreturn void fatal() > { > print("Error"); > exit(1); > } > Thoughts? This looks wrong to me. 'fatal' returns type 'void', except that it doesn't. I would prefer this: null_type fatal() { print("Error"); exit(1); } Here 'null_type' i

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
== Quote from Rainer Deyke (rain...@eldwood.com)'s article > On 10/21/2010 05:54, Iain Buclaw wrote: > > @noreturn void fatal() > > { > > print("Error"); > > exit(1); > > } > > Thoughts? > This looks wrong to me. 'fatal' returns type 'void', except that it > doesn't. I would prefer this:

Re: @noreturn property

2010-10-21 Thread Andrei Alexandrescu
On 10/21/10 12:21 CDT, Rainer Deyke wrote: Feel free to think of a better name than 'null_type'. It's a theory classic called "none" or "bottom". It's the bottom of the subtyping lattice, the subtype of all possible types, a type that can never be instantiated. The feature is nice to have b

Re: @noreturn property

2010-10-21 Thread Leandro Lucarella
Daniel Gibson, el 21 de octubre a las 17:15 me escribiste: > >You want to include in the language what you can do (or at least could) > >do in GDC using: > > > >pragma(GNU_attribute, noreturn)) void fatal() > >{ > > print("Error"); > > exit(1); > >} > > > >? > > > > Obviously he wants a po

Re: @noreturn property

2010-10-21 Thread Nick Sabalausky
"Iain Buclaw" wrote in message news:i9p9li$282...@digitalmars.com... >A few standard library functions, such as 'abort' and 'exit', cannot >return. > However there is no way in DMD to let the compiler know about this. > Currently in D2, you must either have a 'return' or 'assert(0)' statement >

Re: @noreturn property

2010-10-21 Thread bearophile
Nick Sabalausky: > One of the nice things about that is you don't have to provide a "fake" > return type. For instance, with your "@noreturn": "@noreturn int foo()" > would be legal, but wouldn't make any sence. And in a way, even "@noreturn > void foo()" isn't great since a "void" return value

Re: @noreturn property

2010-10-21 Thread Leandro Lucarella
bearophile, el 21 de octubre a las 17:35 me escribiste: > Nick Sabalausky: > > > One of the nice things about that is you don't have to provide a "fake" > > return type. For instance, with your "@noreturn": "@noreturn int foo()" > > would be legal, but wouldn't make any sence. And in a way, even

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
== Quote from Leandro Lucarella (l...@llucax.com.ar)'s article > bearophile, el 21 de octubre a las 17:35 me escribiste: > > Nick Sabalausky: > > > > > One of the nice things about that is you don't have to provide a "fake" > > > return type. For instance, with your "@noreturn": "@noreturn int foo(

Re: @noreturn property

2010-10-21 Thread Rainer Deyke
On 10/21/2010 11:37, Iain Buclaw wrote: > Not sure what you mean when you say that void has only one possible value. To > me, > 'void' for a function means something that does not return any value (or > result). > Are you perhaps confusing it with to, lets say an 'int' function that is > marked

Re: @noreturn property

2010-10-22 Thread Stewart Gordon
On 21/10/2010 12:54, Iain Buclaw wrote: @noreturn What are you taking to be the semantics of '@'? void fatal() { print("Error"); exit(1); } The 'noreturn' keyword would tell the compiler that 'fatal' cannot return, and can then optimise without regard to what would happen if 'fata

Re: @noreturn property

2010-10-22 Thread Iain Buclaw
== Quote from Rainer Deyke (rain...@eldwood.com)'s article > On 10/21/2010 11:37, Iain Buclaw wrote: > > Not sure what you mean when you say that void has only one possible value. > > To me, > > 'void' for a function means something that does not return any value (or > > result). > > Are you perh

Re: @noreturn property

2010-10-22 Thread Stewart Gordon
On 22/10/2010 03:44, Rainer Deyke wrote: A 'void' function returns, therefore it conceptually returns a value. For generic programming, it is useful to treat 'void' as a type like any other, except that it only has one possible value (and therefore encodes no information and requires no storage)

Re: @noreturn property

2010-10-22 Thread bearophile
Ada 95 too has a No_return pragma, see page 12-14 of the PDF file here, it explains various things: http://www.adacore.com/2006/02/02/ada-2005-rationale-exceptions-generics-etc-part-6-of-8/ Bye, bearophile

Re: @noreturn property

2010-10-22 Thread Andrei Alexandrescu
On 10/22/10 19:24 CDT, bearophile wrote: Ada 95 too has a No_return pragma, see page 12-14 of the PDF file here, it explains various things: http://www.adacore.com/2006/02/02/ada-2005-rationale-exceptions-generics-etc-part-6-of-8/ The one cool and interesting thing about non-returning function

Re: @noreturn property

2010-10-25 Thread Steven Schveighoffer
On Fri, 22 Oct 2010 13:22:19 -0400, Stewart Gordon wrote: On 22/10/2010 03:44, Rainer Deyke wrote: A 'void' function returns, therefore it conceptually returns a value. For generic programming, it is useful to treat 'void' as a type like any other, except that it only has one possible value

Re: @noreturn property

2010-10-25 Thread Stewart Gordon
On 25/10/2010 16:18, Steven Schveighoffer wrote: I proposed earlier that maybe you shouldn't be able to create void arrays directly. This would help with the "contains pointers" issue. Indeed, void data is another issue here: http://d.puremagic.com/issues/show_bug.cgi?id=679 Maybe we can com