References in D
Maxim Fomin
maxim at maxim-fomin.ru
Wed Oct 3 04:24:59 PDT 2012
On Wednesday, 3 October 2012 at 10:41:34 UTC, Henning Pohl wrote:
> On Wednesday, 3 October 2012 at 08:11:32 UTC, Franciszek
> Czekała wrote:
>> Agreed. Nullable types are a feature not a bug. There is no
>> need to change it. Bugs occur when you do not know the
>> language rules and make assumptions instead. This can happen
>> whith any language and any rules. As to an example use of
>> nullable references: consider a board game (for example
>> chess). The boards has cells which can be empty or occupied.
>> Model this with an array of class objects representing
>> pieces. null reference means a cell is not occupied. If you
>> want to remove a piece from the board assign null to it and GC
>> will take care of the rest. Now, doing this with full objects
>> representing empty cells would require needless work to define
>> such "null" objects and would be wasteful of memory (typically
>> boards are sparsely populated). Now imagine a really big board
>> and every cell holding references to useless objects
>> simulating null references. It would not make sense. Saying
>> that null references are evil is just propaganda. Let's keep D
>> a sane language.
>
> There is a related question at stackoverflow:
> http://stackoverflow.com/questions/693325/non-nullable-reference-types
>
> As you can see the "nullable references are great" guy has been
> voted down.
>
> I've written like 5k lines of code in D and never felt the need
> of using null. C++'s std::shared_ptr has the same issue, but at
> least it is called pointer.
Since when stackoverflow comment reputation is a word in a
programming languages? Especially, in issue which is subject for
human desire to escape from awareness and then complaining about
arised problems.
More information about the Digitalmars-d
mailing list