Null references redux

Justin Johansson procode at adam-dott-com.au
Sat Sep 26 20:01:46 PDT 2009


Walter Bright Wrote:

> Justin Johansson wrote:
> > Walter, in the heat of this thread I hope you haven't missed the correlation with discussion
> > on "Dispatching on a variant" and noting:
> 
> Thanks for pointing it out. The facilities in D enable one to construct 
> a non-nullable type, and they are appropriate for many designs. I just 
> don't see them as a replacement for *all* reference types.

What you just said made me think that much of this thread is talking at cross-purposes.

Perhaps the problem should be re-framed.

The example

T bar;
bar.foo();    // new magic in hypothetical D doesn't kill the canary just yet

is a bad example to base this discussion on.

Something like

T bar;
mar.foo( bar)

is a better example to consider.

Forgetting about reference types for a moment, consider the following statements:

"An int type is an indiscriminate union of negativeIntegerType, nonNegativeIntegerType, positiveIntegerType and other range-checked integer types.  Passing around int's to
functions that take int arguments, unless full 32 bits of int is what you really mean, is
akin to passing around an indiscriminate union value, which is a no no."

Pondering this might well shed some light and set useful context for the overall discussion.

In other words, it's not so much an argument about calling a method on a reference type,
its more about how to treat any type, value or reference, in type-safe, discriminate, manner.

Just a thought (?)




More information about the Digitalmars-d mailing list