C++ pattern matching is coming
Walter Bright
newshound2 at digitalmars.com
Mon Oct 24 22:26:41 UTC 2022
On 10/24/2022 6:14 AM, Timon Gehr wrote:
> - have more than one lifetime that exceeds the current function's lifetime.
> I.e., multiple distinct return annotations, ideally an arbitrary number, by
> allowing the return annotation to be parameterized by a lifetime variable.
This has been proposed before (I think by deadalnix), and much much earlier
(before Rust) by Bartosz Milewski.
My objection to it was based on its complexity. People have a hard enough time
with `scope`. I am frankly amazed that Rust has been able to sell the idea of
such complicated annotations, though Rust does seem to attract programmers who
revel in such :-) I often hear stories about Rust developers just trying random
annotations to get it to pass the compiler, having little concept of how it
actually works.
The design of dip1000 does not preclude this, however, and it's good to see how
far we can push things and avoid needing such complexity.
> - have such parameterized scope return annotations on fields of aggregates.
Same problem. Let's see how far we can get without them.
P.S. another annotation that nobody is able to use effectively (or correctly) is
C's `restrict` keyword. C++ never bothered to adopt it. Though it was a bad
design anyway, as the compiler cannot check if it is used correctly, it just
generates bad code. ImportC just ignores `restrict`.
More information about the Digitalmars-d
mailing list