January 19, 2021 [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
In C++, the noexcept specifier means you cannot throw anything. In D, the nothrow specifier means you cannot throw Exceptions, but anything else. |
January 19, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Q. Schroll | On 1/19/21 4:50 PM, Q. Schroll wrote:
> In C++, the noexcept specifier means you cannot throw anything.
> In D, the nothrow specifier means you cannot throw Exceptions, but anything else.
Except that in C++, noexcept really means you can throw anything but you're not supposed to. Important distinction...
|
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Wednesday, 20 January 2021 at 01:04:07 UTC, Andrei Alexandrescu wrote:
> On 1/19/21 4:50 PM, Q. Schroll wrote:
>> In C++, the noexcept specifier means you cannot throw anything.
>> In D, the nothrow specifier means you cannot throw Exceptions, but anything else.
>
> Except that in C++, noexcept really means you can throw anything but you're not supposed to. Important distinction...
I've never understood why that is. Do you have any insight into why noexcept is so useless? Why was it designed that way?
|
January 19, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wed, Jan 20, 2021 at 01:17:36AM +0000, Meta via Digitalmars-d wrote: > On Wednesday, 20 January 2021 at 01:04:07 UTC, Andrei Alexandrescu wrote: > > On 1/19/21 4:50 PM, Q. Schroll wrote: > > > In C++, the noexcept specifier means you cannot throw anything. > > > In D, the nothrow specifier means you cannot throw Exceptions, > > > but anything else. > > > > Except that in C++, noexcept really means you can throw anything but you're not supposed to. Important distinction... :-D > I've never understood why that is. Do you have any insight into why noexcept is so useless? Why was it designed that way? I'm not the least surprised. After all, this is C++, the same language that lets you write 'const' on something, and then in the same breath write 'const_cast<...>' to pretend that you never wrote it, all the while your caller still believes that you're honoring your word on the 'const'. Nothing new under the sun. ;-) T -- The most powerful one-line C program: #include "/dev/tty" -- IOCCC |
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wednesday, 20 January 2021 at 01:17:36 UTC, Meta wrote:
> On Wednesday, 20 January 2021 at 01:04:07 UTC, Andrei Alexandrescu wrote:
>> On 1/19/21 4:50 PM, Q. Schroll wrote:
>>> In C++, the noexcept specifier means you cannot throw anything.
>>> In D, the nothrow specifier means you cannot throw Exceptions, but anything else.
>>
>> Except that in C++, noexcept really means you can throw anything but you're not supposed to. Important distinction...
>
> I've never understood why that is. Do you have any insight into why noexcept is so useless? Why was it designed that way?
Why do you think a call to terminate() is useless?
|
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grostad | On Wednesday, 20 January 2021 at 03:26:42 UTC, Ola Fosheim Grostad wrote:
> On Wednesday, 20 January 2021 at 01:17:36 UTC, Meta wrote:
>> On Wednesday, 20 January 2021 at 01:04:07 UTC, Andrei Alexandrescu wrote:
>>> On 1/19/21 4:50 PM, Q. Schroll wrote:
>>>> In C++, the noexcept specifier means you cannot throw anything.
>>>> In D, the nothrow specifier means you cannot throw Exceptions, but anything else.
>>>
>>> Except that in C++, noexcept really means you can throw anything but you're not supposed to. Important distinction...
>>
>> I've never understood why that is. Do you have any insight into why noexcept is so useless? Why was it designed that way?
>
> Why do you think a call to terminate() is useless?
Okay, useless in terms of static guarantees, and definitely compared to nothrow (or even Java's exception specifications IMO). It's not *completely* useless, just mostly useless.
|
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Wednesday, 20 January 2021 at 01:30:15 UTC, H. S. Teoh wrote: > I'm not the least surprised. After all, this is C++, the same language that lets you write 'const' on something, and then in the same breath write 'const_cast<...>' to pretend that you never wrote it, all the while your caller still believes that you're honoring your word on the 'const'. > > Nothing new under the sun. ;-) Modifying it after const cast is undefined behaviour according to cppreference. How would you prevent it? You can do the same in D. Noexcept in c++ makes perfect sense: noexcept(runtimewithoutexceptions) |
January 19, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grostad | On 1/19/21 10:59 PM, Ola Fosheim Grostad wrote:
> On Wednesday, 20 January 2021 at 01:30:15 UTC, H. S. Teoh wrote:
>> I'm not the least surprised. After all, this is C++, the same language that lets you write 'const' on something, and then in the same breath write 'const_cast<...>' to pretend that you never wrote it, all the while your caller still believes that you're honoring your word on the 'const'.
>>
>> Nothing new under the sun. ;-)
>
> Modifying it after const cast is undefined behaviour according to cppreference. How would you prevent it? You can do the same in D.
Only if the real item is actually const. This is literally the first example on cppreference:
int i = 3; // i is not declared const
const int& rci = i;
const_cast<int&>(rci) = 4; // OK: modifies i
-Steve
|
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Wednesday, 20 January 2021 at 03:56:24 UTC, Meta wrote:
> Okay, useless in terms of static guarantees, and definitely compared to nothrow (or even Java's exception specifications IMO). It's not *completely* useless, just mostly useless.
In c++ most things are related to performance, and then you leave expensive static analysis to optional external tools.
Noexecpt tells the codegen to emit more efficient code.
|
January 20, 2021 Re: [Joke] C++ and D namings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wednesday, 20 January 2021 at 04:15:24 UTC, Steven Schveighoffer wrote:
> Only if the real item is actually const. This is literally the first example on cppreference:
>
> int i = 3; // i is not declared const
> const int& rci = i;
> const_cast<int&>(rci) = 4; // OK: modifies i
>
How is this different from D? How does this lead to different code gen?
|
Copyright © 1999-2021 by the D Language Foundation