Date: Tue, 29 Oct 2024 11:06:55 -0700
> > But if p is nullptr, then it is not pointing at a valid object, so that statement does not make semantical sense.
>
> Yeah I agree; currently in C++23, invoking a method on a nullptr
> doesn't make sense.
You appear to be focussing only on the words on the page. I'm talking
about what the statement means.
> > That one can concoct some mechanism that it will do something is rather beside the point.
>
> I'm proposing a change to the language.
Yes, we know. What's missing is the justification. Changing the
language just because we can is not useful. What appears to be
missing is an articulation of a problem that this solves, alternatives
to the proposed solution, and why the proposed solution was selected
over the alternatives. Right now, this appears to be a solution in
search of a problem.
> > Additionally, what happens if fn() is a pure virtual function? Yay, more UB, just harder to find?
>
> In my original post, I suggested a syntax such as:
>
> class MyClass friend nullptr { ... };
>
> to indicate to the compiler that you can invoke methods on a nullptr
> for this class. And so if 'MyClass' contains any methods lacking an
> implementation, the compiler shall terminate compilation and issue a
> diagnostic.
You don't necessarily know if there's no implementation at compile
time. Just because a function is pure virtual, doesn't mean that it
doesn't have an implementation.
>
> Yeah I agree; currently in C++23, invoking a method on a nullptr
> doesn't make sense.
You appear to be focussing only on the words on the page. I'm talking
about what the statement means.
> > That one can concoct some mechanism that it will do something is rather beside the point.
>
> I'm proposing a change to the language.
Yes, we know. What's missing is the justification. Changing the
language just because we can is not useful. What appears to be
missing is an articulation of a problem that this solves, alternatives
to the proposed solution, and why the proposed solution was selected
over the alternatives. Right now, this appears to be a solution in
search of a problem.
> > Additionally, what happens if fn() is a pure virtual function? Yay, more UB, just harder to find?
>
> In my original post, I suggested a syntax such as:
>
> class MyClass friend nullptr { ... };
>
> to indicate to the compiler that you can invoke methods on a nullptr
> for this class. And so if 'MyClass' contains any methods lacking an
> implementation, the compiler shall terminate compilation and issue a
> diagnostic.
You don't necessarily know if there's no implementation at compile
time. Just because a function is pure virtual, doesn't mean that it
doesn't have an implementation.
Received on 2024-10-29 18:07:08