Empty VS null array?

Regan Heath regan at netmail.co.nz
Mon Oct 21 08:42:45 PDT 2013


On Mon, 21 Oct 2013 12:54:56 +0100, Jonathan M Davis <jmdavisProg at gmx.com>  
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/


More information about the Digitalmars-d mailing list