On Mon, 21 Oct 2013 12:54:56 +0100, Jonathan M Davis <[email protected]> wrote:

On Monday, October 21, 2013 11:58:07 Regan Heath wrote:
If what you say is true then slices would and could never be null... If
that were the case I would stop complaining and simply "box" them with
Nullable when I wanted a reference type. But, D's strings/slices are some
kind of mutant half reference half value type, and that's the underlying
problem here.

Yeah, dynamic arrays in D are just plain weird. They're halfway between
reference types and value types, and it definitely causes confusion, and it totally screws with null (which definitely sucks). But they mostly work really well the way that they are, and in general, the way that slices work works really well. So, I don't know if what we have is ultimately the right design
or not. I definitely don't like how null works for arrays though.

Given how they work, we probably would have been better off if they couldn't be null. The ptr obviously could be null, but the array itself arguably shouldn't be able to be null. If we did that, then it would be clear that null wouldn't work with arrays, and no one would try. It would still kind of suck, since you wouldn't have null, but then at least it would be clear that null wouldn't work with arrays instead of having a situation where it kind of does and kind
of doesn't.

Agreed. This is preferable to the current situation, even if it's not my personal preferred solution.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to