Davidson Corry:

> The only reason to have an 'out(result)' form is to declare that we 
> intend to use the magic 'result' symbol in the post-condition testing.

This is not true. Currently 'result' has nothing magic, it's just a variable 
name, you are free to change it:


int result;
int foo(int x, out int result)
    out(y) {
        assert(y > 0);
    }
    body {
        result = 10;
        return -1;
    }
void main() {
    int z;
    auto s = foo(4, z);
}


> I think the thing to do is to just declare 'out' as we currently do [or 
> 'scope(out)' as I am proposing], and treat the 'result' symbol magically 
> in the post-condition code whether or not it is pre-declared -- that is, 
> have the compiler find it and interpret it as the magic returned-value.

In some rare situations magic is acceptable, but it's dangerous, and in most 
situations it's better to avoid it. Unless "result" becomes a keyword (so you 
can't assign something to it by mistake), then the current syntax with 
out(someConstVariableName) seems better.

Bye,
bearophile

Reply via email to