nullable done right, was #Spec

Jimmy Cao jcao219 at gmail.com
Sun Nov 7 13:17:39 PST 2010


On Sun, Nov 7, 2010 at 2:53 PM, BLS <windevguy at hotmail.de> wrote:

> The following code does not fail at compile-time or run-time because the if
> statement proves that the call is safe:
> class Foo
>
>    def bar(s as String?)
>        if s  # same as "if s is not nil"
>            print Utils.countChars(s, c'x')
>
>
> Please note the question mark "?" on String? forces a compile time check.
>
> --As a side note
> The sample snippet is written Cobra (not Boo).. CLR NET.
> Cobra's DBC is heavily influenced by D !
>
> Bearophile could be interested; so here the link
>
> http://cobra-language.com/docs/quality/
> Bjoern
>

I've played with Cobra before, and I agree that Cobra does it very well.

I hope that D allows non-nullable types so that those seg faults/access
violations can be prevented/caught easily at compile-time.
(for the sake of increasing the self-documenting ability of code, the safety
of code, and even the quality code, as described in the link above)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101107/f421f999/attachment-0001.html>


More information about the Digitalmars-d mailing list