NonNull template
Walter Bright
newshound2 at digitalmars.com
Fri Apr 18 02:35:56 UTC 2025
On 4/17/2025 10:36 AM, Dave P. wrote:
> First to support classes, you’d have to make a slight change
Sure, you'd want to overload the NonNull template with one that takes a class
type parameter.
> It works, but the syntax/defaults is backwards. Why does the unusual case of a
> nullable pointer get the nice syntax while the common case gets the
> `NonNull!(int*)` syntax? Who is going to write that all over their code?
Backwards compatibility. The NonNull is the addition, the nullable is the
existing. Changing the existing behavior would be a massive disruption.
Anyhow, it's a good idea to see how far one can take the metaprogramming
approach to what you want, before changing the core language.
More information about the Digitalmars-d
mailing list