struct init property

Jonathan M Davis jmdavisProg at gmx.com
Thu Aug 23 16:51:27 PDT 2012


On Friday, August 24, 2012 01:35:56 Namespace wrote:
> > If you want something that isn't nullable, you'll need a type
> > which which
> > isn't nullable, which means using a struct. I know that you
> > want non-nullable
> > references, but for D2, the best that you're going to get is a
> > struct which
> > wraps a class.
> > 
> > - Jonathan M Davis
> 
> That would be fine if i only have to write:
> 
> [code]
> void test(NotNullable!Foo f) {
> [/code]
> 
> and not
> 
> [code]
> Foo f = new Foo();
> NotNullable!Foo nf = f;
> test(nf)
> [/code]
> 
> as well.

I would expect you to be able to do

test(NotNullable!Foo(new Foo));

and with a helper function, you could have something like

test(notNullable(new Foo));

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list