"Expressive vs. permissive languages" and bugs

bearophile bearophileHUGS at lycos.com
Sat Oct 23 17:00:09 PDT 2010


Roman Ivanov:

> The ability to define different integer types seemed nice. I like clarity.

It _is_ nice, if the compiler is able to enforce those bounds.


> (For example, I don't like that C# uses int for sizes, instead of uint.)

In theory I agree a lot with you, that signed sizes is wrong. In practice, given that:
- D uses the silly signed/unsigned promotion rules of C
- D has no integral overflows yet
- D even lacks warning about mixing signed and unsigned variables in expressions, that even C GCC has

The result of those three facts makes the usage of integers in D safer. In the end I use signed lengths and indexes everywhere it's safe and sane to do (but not everywhere).
So I have asked the opposite of what I and you like:
http://d.puremagic.com/issues/show_bug.cgi?id=3843


> At the same time, I can easily see how that would get out of hand and
> sabotage readability.

This is a real risk, so you need to design the syntax carefully.


> One of the issues mentioned in the articles always bothered me in C# and
> Java. Why all the reference types are nullable by default? Most of the
> time when an object is assigned a null value it is wrong and should
> immediately generate an exception. I 5% of the cases when I want nulls,
> I can ask for the explicitly.

This is a topic that was discussed hotly during the last stages of the finalization of D2 (I haven't understood why that idea was in the end refused).

Anyway, even if now and forever in D pointers/references on default are nullable, an annotation + some semantics may be added still to tag the pointers/references you don't want nullable. I have started an enhancement request here some time ago:
http://d.puremagic.com/issues/show_bug.cgi?id=4571

Thank you for your comments,
bye,
bearophile


More information about the Digitalmars-d mailing list