Jump to page: 1 25  
Page
Thread overview
January 19
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
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
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
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
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
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
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
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
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
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?

« First   ‹ Prev
1 2 3 4 5