@noreturn ?

2011-12-24 Thread bearophile
nt val); #include _Noreturn void abort(void); #include _Noreturn void exit(int status); #include _Noreturn void _Exit(int status); #include _Noreturn void quick_exit(int status); GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so

@noreturn?

2012-05-13 Thread Alex Rønne Petersen
Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go? In writing unwinding mechanisms for my VM, I find myself actually needing some sort of @noreturn function attribute that would tell the compiler that the

@noreturn property

2010-10-21 Thread Iain Buclaw
ld be nice however if you can give hints to the compiler to let it know that a function is never going to return. Example: @noreturn void fatal() { print("Error"); exit(1); } The 'noreturn' keyword would tell the compiler that 'fatal' cannot return, and can

Re: @noreturn ?

2011-12-24 Thread Vladimir Panteleev
On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote: GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a @noreturn function attribute useful in D too? Maybe to implement a better

Re: @noreturn ?

2011-12-24 Thread Caligo
On Sat, Dec 24, 2011 at 2:09 PM, bearophile wrote: > > I don't fully understand why such attribute is so useful in C programs > > Bye, > bearophile > Functions are like people. Sometimes they go places that's so beautiful that they never want to return.

Re: @noreturn ?

2011-12-24 Thread Andrei Alexandrescu
On 12/24/2011 06:58 PM, Vladimir Panteleev wrote: On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote: GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a @noreturn function attr

Re: @noreturn ?

2011-12-25 Thread Jonathan M Davis
On Saturday, December 24, 2011 22:26:02 Andrei Alexandrescu wrote: > On 12/24/2011 06:58 PM, Vladimir Panteleev wrote: > > On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote: > >> GNU C has a noreturn attribute since a lot of time. I don't fully > >>

Re: @noreturn?

2012-05-13 Thread Iain Buclaw
On 13 May 2012 17:13, Alex Rønne Petersen wrote: > Hi, > > If memory serves me right, there were some proposals in the past to add a > @noreturn attribute to the language. Where did this go? > > In writing unwinding mechanisms for my VM, I find myself actually needing > s

Re: @noreturn?

2012-05-14 Thread bearophile
Alex Rønne Petersen: In writing unwinding mechanisms for my VM, I find myself actually needing some sort of @noreturn function attribute that would tell the compiler that the function does not return, Maybe Walter will listen you more if you show an example of where/why you would use

Re: @noreturn?

2012-05-14 Thread Alex Rønne Petersen
On 14-05-2012 14:13, Alex Rønne Petersen wrote: On 14-05-2012 13:53, bearophile wrote: Alex Rønne Petersen: In writing unwinding mechanisms for my VM, I find myself actually needing some sort of @noreturn function attribute that would tell the compiler that the function does not return

Re: @noreturn?

2012-05-14 Thread Alex Rønne Petersen
On 14-05-2012 13:53, bearophile wrote: Alex Rønne Petersen: In writing unwinding mechanisms for my VM, I find myself actually needing some sort of @noreturn function attribute that would tell the compiler that the function does not return, Maybe Walter will listen you more if you show an

Re: @noreturn?

2012-05-14 Thread Iain Buclaw
On 14 May 2012 13:21, Alex Rønne Petersen wrote: > On 14-05-2012 14:13, Alex Rønne Petersen wrote: >> >> On 14-05-2012 13:53, bearophile wrote: >>> >>> Alex Rønne Petersen: >>> >>>> In writing unwinding mechanisms for my VM, I find myself

Re: @noreturn?

2012-05-14 Thread Timon Gehr
On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go? In writing unwinding mechanisms for my VM, I find myself actually needing some sort of @noreturn function

Re: @noreturn?

2012-05-14 Thread Alex Rønne Petersen
On 14-05-2012 23:59, Timon Gehr wrote: On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go? In writing unwinding mechanisms for my VM, I find myself actually

Re: @noreturn?

2012-05-14 Thread Timon Gehr
On 05/15/2012 12:14 AM, Alex Rønne Petersen wrote: On 14-05-2012 23:59, Timon Gehr wrote: On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go? In writing

Re: @noreturn?

2012-05-14 Thread Jonathan M Davis
On Monday, May 14, 2012 23:59:19 Timon Gehr wrote: > On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: > > Hi, > > > > If memory serves me right, there were some proposals in the past to add > > a @noreturn attribute to the language. Where did this go? > > &g

Re: @noreturn?

2012-05-14 Thread Artur Skawina
On 05/14/12 23:59, Timon Gehr wrote: > On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: >> Hi, >> >> If memory serves me right, there were some proposals in the past to add >> a @noreturn attribute to the language. Where did this go? >> >> In writing unwind

Re: @noreturn?

2012-05-15 Thread Iain Buclaw
;>> If memory serves me right, there were some proposals in the past to add >>>> a @noreturn attribute to the language. Where did this go? >>>> >>>> In writing unwinding mechanisms for my VM, I find myself actually >>>> needing some sort of @nore

Re: @noreturn?

2012-05-15 Thread Iain Buclaw
On 14 May 2012 22:59, Timon Gehr wrote: > On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: >> >> Hi, >> >> If memory serves me right, there were some proposals in the past to add >> a @noreturn attribute to the language. Where did this go? >> >> In w

Re: @noreturn?

2012-05-16 Thread Steven Schveighoffer
On Mon, 14 May 2012 17:59:19 -0400, Timon Gehr wrote: On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go? In writing unwinding mechanisms for my VM, I find

Re: @noreturn?

2012-05-16 Thread Timon Gehr
On 05/16/2012 02:27 PM, Steven Schveighoffer wrote: On Mon, 14 May 2012 17:59:19 -0400, Timon Gehr wrote: On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote: Hi, If memory serves me right, there were some proposals in the past to add a @noreturn attribute to the language. Where did this go

Re: @noreturn?

2012-05-16 Thread Steven Schveighoffer
bug, they are not for DMD. OK, then I would support this as a method of specifying @noreturn BTW, is this bug reported? -Steve

Re: @noreturn?

2012-05-16 Thread Timon Gehr
supposed to be part of the method signature. Due to a bug, they are not for DMD. OK, then I would support this as a method of specifying @noreturn BTW, is this bug reported? -Steve Yes. http://d.puremagic.com/issues/show_bug.cgi?id=6549 Stewart has turned it into an enhancement, but it is

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
'assert(0)' > statement at the end of a function body. It would be nice however if you > can give hints to the compiler to let it know that a function is never > going to return. > > Example: > > @noreturn void fatal() > { > print("Error"); >

Re: @noreturn property

2010-10-21 Thread Steven Schveighoffer
ntly 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 the compiler to let it know that a function is never going to return. Example: @noreturn void fatal() { print("Error&qu

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
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 the compiler to let it know that a function is never > > going t

Re: @noreturn property

2010-10-21 Thread Lars T. Kyllingstad
gt;>> you can give hints to the compiler to let it know that a function is >>> never going to return. >>> >>> Example: >>> >>> @noreturn void fatal() >>> { >>> print("Error"); >>> exit(1); >>> } >>

Re: @noreturn property

2010-10-21 Thread Justin Johansson
tement at the end of a function body. It would be nice however if you can give hints to the compiler to let it know that a function is never going to return. Example: @noreturn void fatal() { print("Error"); exit(1); } The 'noreturn' keyword would tell the compil

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
r 'assert(0)' statement at > the end of a function body. It would be nice however if you can give hints to > the compiler to let it know that a function is never going to return. > > Example: > > @noreturn void fatal() > { > print("Error"); >

Re: @noreturn property

2010-10-21 Thread Daniel Gibson
#x27;return' or 'assert(0)' statement at the end of a function body. It would be nice however if you can give hints to the compiler to let it know that a function is never going to return. Example: @noreturn void fatal() { print("Error"); exit(1); } The 'noretu

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
ler 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 > > the compiler to let it know that a function is never going t

Re: @noreturn property

2010-10-21 Thread Iain Buclaw
hints > >> to > >> the compiler to let it know that a function is never going to return. > >> > >> Example: > >> > >> @noreturn void fatal() > >> { > >> print("Error"); > >> exit(1); > >> } > >>

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()

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'

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"); > >

Re: @noreturn property

2010-10-21 Thread Nick Sabalausky
r 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 > the compiler to let it know that a function is never going to return. > > Example: > > @noreturn void fatal() > { >

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 "@nor

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()" > >

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. Fo

Re: @noreturn property

2010-10-21 Thread Rainer Deyke
nt' function that is > marked as > noreturn? 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 enc

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 optimis

Re: @noreturn property

2010-10-22 Thread Iain Buclaw
value (or > > result). > > Are you perhaps confusing it with to, lets say an 'int' function that is > > marked as > > noreturn? > A 'void' function returns, therefore it conceptually returns a value. > For generic programming, it is useful to tr

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

proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
C compilers (and by extension C++ compilers) usually have an extension which allows a function to be marked as one that never returns. The point of this is it enables improved data flow analysis and better code being generated. Noreturn functions crop up in things like assert's and enfo

Re: proposed @noreturn attribute

2017-07-08 Thread Nicholas Wilson via Digitalmars-d
. Noreturn functions crop up in things like assert's and enforce's. DMD internally hardcodes a few functions it knows about that are noreturn, and the DMD optimizer and codegen take advantage of it. But when people write their own assert's and enforce's, this falls apart. Whi

Re: proposed @noreturn attribute

2017-07-08 Thread bachmeier via Digitalmars-d
On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Having an @noreturn attribute will take care of that: @noreturn void ThisFunctionExits(); Why should this be an attribute rather than a pragma? It looks to me that the goal is to pass information to the compiler, and

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 7/8/17 6:15 AM, Walter Bright wrote: Has anyone a better idea? Does anyone want to write a DIP for this? An attribute is fine. A more PL-minded possibility is to return a specific type: struct None { @disable this(); @disable this(this); @disable @property None init(); } None

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 7/8/17 7:07 AM, bachmeier wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Having an @noreturn attribute will take care of that: @noreturn void ThisFunctionExits(); Why should this be an attribute rather than a pragma? So it's part of the summary of the fun

Re: proposed @noreturn attribute

2017-07-08 Thread Stefan Koch via Digitalmars-d
On Saturday, 8 July 2017 at 12:17:57 UTC, Andrei Alexandrescu wrote: On 7/8/17 6:15 AM, Walter Bright wrote: Has anyone a better idea? Does anyone want to write a DIP for this? An attribute is fine. A more PL-minded possibility is to return a specific type: struct None { @disable this()

Re: proposed @noreturn attribute

2017-07-08 Thread bachmeier via Digitalmars-d
On Saturday, 8 July 2017 at 12:18:38 UTC, Andrei Alexandrescu wrote: On 7/8/17 7:07 AM, bachmeier wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Having an @noreturn attribute will take care of that: @noreturn void ThisFunctionExits(); Why should this be an

Re: proposed @noreturn attribute

2017-07-08 Thread Jonathan Marler via Digitalmars-d
. Noreturn functions crop up in things like assert's and enforce's. DMD internally hardcodes a few functions it knows about that are noreturn, and the DMD optimizer and codegen take advantage of it. But when people write their own assert's and enforce's, this falls apart. Whi

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 07/08/2017 08:20 AM, Stefan Koch wrote: ... since it's going to be special cased by the compiler we might as well hardwire a type called none. Walter and I have repeated experience with moving compiler smarts into library artifacts. Sometimes it's arguably not the best way to go, but in th

Re: proposed @noreturn attribute

2017-07-08 Thread Jack Stouffer via Digitalmars-d
On Saturday, 8 July 2017 at 11:07:32 UTC, bachmeier wrote: Why should this be an attribute rather than a pragma? I agree. There's no reason I can think of as to why the no-return should be part of the ABI.

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 07/08/2017 01:14 PM, Jack Stouffer wrote: On Saturday, 8 July 2017 at 11:07:32 UTC, bachmeier wrote: Why should this be an attribute rather than a pragma? I agree. There's no reason I can think of as to why the no-return should be part of the ABI. If present in the signature of the funct

Re: proposed @noreturn attribute

2017-07-08 Thread Stefan Koch via Digitalmars-d
On Saturday, 8 July 2017 at 17:14:32 UTC, Andrei Alexandrescu wrote: What is the signature of a function that logs something to a file and ends in assert(0)? I do get your point. However I still doubt that this is worth a the additional language complexity. Usually the clue would be in t

Re: proposed @noreturn attribute

2017-07-08 Thread John Colvin via Digitalmars-d
On Saturday, 8 July 2017 at 12:17:57 UTC, Andrei Alexandrescu wrote: On 7/8/17 6:15 AM, Walter Bright wrote: Has anyone a better idea? Does anyone want to write a DIP for this? An attribute is fine. A more PL-minded possibility is to return a specific type: struct None { @disable this()

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 7/8/17 2:26 PM, John Colvin wrote: I wonder if some lessons from Haskell's "bottom" type would be relevant here. Affirmative. The nice touch of bottom (heh) is that it's convertible to anything, so you can use it in complex expressions as a wildcard. -- Andrei

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 7/8/17 1:30 PM, Stefan Koch wrote: On Saturday, 8 July 2017 at 17:14:32 UTC, Andrei Alexandrescu wrote: What is the signature of a function that logs something to a file and ends in assert(0)? I do get your point. However I still doubt that this is worth a the additional language compl

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 3:52 AM, Nicholas Wilson wrote: consider that GDC and LDC already both have that attribute courtesy of their backends (@attribute("noreturn") and @llvmAttr("noreturn") respectively). One could argue that since "noreturn" changes the interface of a fu

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
ver return. That is a scathingly brilliant idea. It has another nice effect - the compiler doesn't have to diagnose: @noreturn int foo(); as an error! Me like.

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
anges the implementation of a function such that it now returns, it will break any compiled code that relied on it being noreturn. This is why, for example, nothrow is part of the signature.

Re: proposed @noreturn attribute

2017-07-08 Thread H. S. Teoh via Digitalmars-d
ot;) that the type None is impossible to create > > and copy/move from a function, and therefore decrees the function > > will never return. > > That is a scathingly brilliant idea. It has another nice effect - the > compiler doesn't have to diagnose: > >@nor

Re: proposed @noreturn attribute

2017-07-08 Thread H. S. Teoh via Digitalmars-d
t; everyone rolls their own None type with different names. An attribute > has the advantage that it will be universally understood. [...] Also, a @noreturn attribute would allow overriding a non-void class method with a @noreturn one (e.g. the derived class is a sentinel object that forces an exc

Re: proposed @noreturn attribute

2017-07-08 Thread Vladimir Panteleev via Digitalmars-d
On Saturday, 8 July 2017 at 12:17:57 UTC, Andrei Alexandrescu wrote: @disable @property None init(); You meant static here I guess. The compiler detects (without having anything hardwired about the particular type "None") that the type None is impossible to create and copy/move from a fu

Re: proposed @noreturn attribute

2017-07-08 Thread Vladimir Panteleev via Digitalmars-d
On Saturday, 8 July 2017 at 21:03:57 UTC, Vladimir Panteleev wrote: This particular one is countered by also adding a disabled destructor. Oops, never mind that - this makes the function uncallable.

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 1:20 PM, H. S. Teoh via Digitalmars-d wrote: Hmmm. Just to clarify, what exactly does @noreturn include? If I have a function that calls exit(), that's @noreturn? What about a function that always throws? Or a function that calls exec()? A function that always ends in assert(

Re: proposed @noreturn attribute

2017-07-08 Thread Martin Nowak via Digitalmars-d
) that the type None is impossible to create and copy/move from a function, and therefore decrees the function will never return. That's a lot more complex (for the compiler and to explain) than using a simple magic @noreturn attribute. Agreed that this is rarely needed but sometimes ni

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 4:36 PM, Martin Nowak wrote: That's a lot more complex (for the compiler and to explain) than using a simple magic @noreturn attribute. Agreed that this is rarely needed but sometimes nice to have. Far from being important though ;). We have types that cannot be named (Vold

Re: proposed @noreturn attribute

2017-07-08 Thread crimaniak via Digitalmars-d
; and call this type 'noreturn'. noreturn functionFoo(bla-bla-bla);

Re: proposed @noreturn attribute

2017-07-08 Thread sarn via Digitalmars-d
On Sunday, 9 July 2017 at 00:16:50 UTC, Walter Bright wrote: We have types that cannot be named (Voldemort types), types that have no type (void), I suppose that types that cannot exist will fill out the edge cases of the menagerie. I assume there is a standard jargon for this - does anyone kn

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 7:01 PM, sarn wrote: On Sunday, 9 July 2017 at 00:16:50 UTC, Walter Bright wrote: We have types that cannot be named (Voldemort types), types that have no type (void), I suppose that types that cannot exist will fill out the edge cases of the menagerie. I assume there is a standar

Re: proposed @noreturn attribute

2017-07-08 Thread H. S. Teoh via Digitalmars-d
cannot create any instances of it. :-P From the POV of types as sets of possible values, it's a type that corresponds with an empty set. However, then we cannot distinguish between void (which is also by definition a type that has no instances) and noreturn. I'm not sure how to interp

Re: proposed @noreturn attribute

2017-07-08 Thread Meta via Digitalmars-d
On Sunday, 9 July 2017 at 02:25:50 UTC, Walter Bright wrote: (D already has a `void` type, so can't use Haskell's word.) Just so we are all on the same page, from a type-theory perspective void is a unit type (it has 1 value), not an uninhabited type (it has no values, i.e. Haskell's _|_ (bot

Re: proposed @noreturn attribute

2017-07-08 Thread Meta via Digitalmars-d
On Sunday, 9 July 2017 at 04:23:15 UTC, Meta wrote: On Sunday, 9 July 2017 at 02:25:50 UTC, Walter Bright wrote: (D already has a `void` type, so can't use Haskell's word.) Just so we are all on the same page, from a type-theory perspective void is a unit type (it has 1 value), not an uninha

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 07/08/2017 10:25 PM, Walter Bright wrote: On 7/8/2017 7:01 PM, sarn wrote: On Sunday, 9 July 2017 at 00:16:50 UTC, Walter Bright wrote: We have types that cannot be named (Voldemort types), types that have no type (void), I suppose that types that cannot exist will fill out the edge cases o

Re: proposed @noreturn attribute

2017-07-08 Thread Andrei Alexandrescu via Digitalmars-d
On 07/08/2017 05:03 PM, Vladimir Panteleev wrote: On Saturday, 8 July 2017 at 12:17:57 UTC, Andrei Alexandrescu wrote: @disable @property None init(); You meant static here I guess. The compiler detects (without having anything hardwired about the particular type "None") that the type No

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 9:23 PM, Meta wrote: On Sunday, 9 July 2017 at 02:25:50 UTC, Walter Bright wrote: (D already has a `void` type, so can't use Haskell's word.) Just so we are all on the same page, from a type-theory perspective void is a unit type (it has 1 value), not an uninhabited type (it has n

Re: proposed @noreturn attribute

2017-07-08 Thread Walter Bright via Digitalmars-d
On 7/8/2017 9:32 PM, Meta wrote: On Sunday, 9 July 2017 at 04:23:15 UTC, Meta wrote: On Sunday, 9 July 2017 at 02:25:50 UTC, Walter Bright wrote: (D already has a `void` type, so can't use Haskell's word.) Just so we are all on the same page, from a type-theory perspective void is a unit typ

Re: proposed @noreturn attribute

2017-07-09 Thread Mr.D via Digitalmars-d
On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Has anyone a better idea? What about scope(exit) assert(0); ?

Re: proposed @noreturn attribute

2017-07-09 Thread Timon Gehr via Digitalmars-d
On 09.07.2017 07:44, Walter Bright wrote: On 7/8/2017 9:32 PM, Meta wrote: On Sunday, 9 July 2017 at 04:23:15 UTC, Meta wrote: On Sunday, 9 July 2017 at 02:25:50 UTC, Walter Bright wrote: (D already has a `void` type, so can't use Haskell's word.) Just so we are all on the same page, from a

Re: proposed @noreturn attribute

2017-07-09 Thread Daniel N via Digitalmars-d
On Sunday, 9 July 2017 at 10:31:47 UTC, Mr.D wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Has anyone a better idea? What about scope(exit) assert(0); ? void func() out { assert(0); } body { }

Re: proposed @noreturn attribute

2017-07-09 Thread Steven Schveighoffer via Digitalmars-d
On Sunday, 9 July 2017 at 10:51:50 UTC, Daniel N wrote: On Sunday, 9 July 2017 at 10:31:47 UTC, Mr.D wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Has anyone a better idea? What about scope(exit) assert(0); ? void func() out { assert(0); } body { } Yes, this! -

Re: proposed @noreturn attribute

2017-07-09 Thread Nicholas Wilson via Digitalmars-d
On Sunday, 9 July 2017 at 10:59:43 UTC, Steven Schveighoffer wrote: On Sunday, 9 July 2017 at 10:51:50 UTC, Daniel N wrote: On Sunday, 9 July 2017 at 10:31:47 UTC, Mr.D wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Has anyone a better idea? What about scope(exit) as

Re: proposed @noreturn attribute

2017-07-09 Thread Walter Bright via Digitalmars-d
On 7/9/2017 3:48 AM, Timon Gehr wrote: It is indeed incorrect, [...] Thanks!

Re: proposed @noreturn attribute

2017-07-09 Thread Walter Bright via Digitalmars-d
On 7/9/2017 3:31 AM, Mr.D wrote: scope(exit) assert(0); It needs to be part of the function signature, not the function implementation.

Re: proposed @noreturn attribute

2017-07-09 Thread Steven Schveighoffer via Digitalmars-d
On 7/9/17 7:07 AM, Nicholas Wilson wrote: On Sunday, 9 July 2017 at 10:59:43 UTC, Steven Schveighoffer wrote: On Sunday, 9 July 2017 at 10:51:50 UTC, Daniel N wrote: On Sunday, 9 July 2017 at 10:31:47 UTC, Mr.D wrote: On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote: Has anyone

Re: proposed @noreturn attribute

2017-07-09 Thread Nicholas Wilson via Digitalmars-d
ribute is the simplest way to achieve the goals of: * documentation, is doesn't get much simpler than @noreturn * optimisation, its already in LDC and GDC, just under a different name * compatibility between compilers, its as simple as an alias in a version statement per compiler.

Re: proposed @noreturn attribute

2017-07-09 Thread Andrei Alexandrescu via Digitalmars-d
On 7/9/17 1:36 AM, Walter Bright wrote: If we wanted to be cute we could use `typeof()` to represent this type as there is no value you can give to typeof such that it returns the bottom type. It also avoids having to come up with some special symbol or name for it. That is indeed an intere

Re: proposed @noreturn attribute

2017-07-09 Thread Andrei Alexandrescu via Digitalmars-d
On 7/9/17 7:26 AM, Steven Schveighoffer wrote: On 7/9/17 7:07 AM, Nicholas Wilson wrote: On Sunday, 9 July 2017 at 10:59:43 UTC, Steven Schveighoffer wrote: On Sunday, 9 July 2017 at 10:51:50 UTC, Daniel N wrote: On Sunday, 9 July 2017 at 10:31:47 UTC, Mr.D wrote: On Saturday, 8 July 2017 at

Re: proposed @noreturn attribute

2017-07-09 Thread Stefan Koch via Digitalmars-d
On Sunday, 9 July 2017 at 13:13:28 UTC, Andrei Alexandrescu wrote: On 7/9/17 1:36 AM, Walter Bright wrote: If we wanted to be cute we could use `typeof()` to represent this type as there is no value you can give to typeof such that it returns the bottom type. It also avoids having to come up

Re: proposed @noreturn attribute

2017-07-09 Thread Steven Schveighoffer via Digitalmars-d
On 7/9/17 9:16 AM, Andrei Alexandrescu wrote: I wonder why there's so much attraction to exotic approaches when encoding "no return" with types has so much established theory and practice with it. -- Andrei Your definition of exotic differs from mine. I haven't seen another solution other

  1   2   3   >