On Thu, 03 Sep 2009 11:50:55 -0400, Leandro Lucarella <llu...@gmail.com> wrote:

Steven Schveighoffer, el  3 de septiembre a las 11:22 me escribiste:
On Thu, 03 Sep 2009 10:40:13 -0400, Leandro Lucarella

>Maybe this is a very silly question, but what is exactly the difference
>between Optional!T o/isNull(o) and T* o/o is null?

The difference is you don't have to store the T somewhere else.

That doesn't seems like a big problem having a GC.

There are performance concerns, you need 16 bytes minimum to store a value on the heap, so a 4-byte integer becomes 16 bytes on the heap. And the GC is way slower than storing on the stack.


That is, an Optional!T contains both the value if it is not null AND
whether it is null or not.  With a T*, the value is stored elsewhere,
and you may have aliasing problems.

Ok, this seems like a reasonable point. So Optional!T is a value type,
right?

If T is a value type, yes. I'm not sure what Andrei has in mind if T is a reference type.

-Steve

Reply via email to