A few questions

Simen Kjaeraas simen.kjaras at gmail.com
Fri Jul 27 08:14:05 PDT 2012


On Fri, 27 Jul 2012 16:39:49 +0200, Namespace <rswhite4 at googlemail.com>  
wrote:

> What's wrong with the solution that
>
> void some_function(Foo? f) {
>
> is converted to
>
> void some_function(Foo f, string filename = __FILE__, uint line =  
> __LINE__)  in {
>      assert(f !is null, std.string.format("Null Object @ File %s on Line  
> %d.", filename, line));
> } body {
>
> ? It isn't a huge effort for the compiler, or?

Nope.

But, that's just a simple assertion. If we'd had real non-nullable types,
we could remove the check completely, because you'd know it held a valid
object.

Now, a library solution has certain limitations a built-in solution would
not - for instance, new X would return non-nullable.

-- 
Simen


More information about the Digitalmars-d-learn mailing list