Using out qualifier instead of *, how to pass null?

Derek Parnell derek at psych.ward
Thu Feb 1 02:48:52 PST 2007

On Thu, 01 Feb 2007 03:00:01 -0500, Rick Mann wrote:

> In wrapping this C API, I've been going back and forth
> between converting "Foo*" output parameters to "out Foo". 
> I prefer the latter, as I don't have to take the address
> at the call site, but I don't seem to be able to pass null
> (which the API allows, meaning, "I'm not interested in
> this return value").
> Am I just stuck with Foo*? Alternatively, I can overload
> the C function with D wrappers, I suppose. Hmm. That's
> probably best.

Is not possible to use a 'null' object ... ?

class Foo {}
void Bar(out Foo f) 
  if (f is null)
Foo NullFoo;
Foo RealFoo = new Foo;


Derek Parnell

More information about the Digitalmars-d-learn mailing list