On 10/29/2011 8:26 PM, bearophile wrote:
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:

Ah. I did not know that. Thanks for the info.

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.

Ah, again. 'Result' *is* magic in Eiffel (in all functions). I assumed that it was equivalently magic in D (in the post-condition context only), and named that way *because* of the Eiffel usage. You learn something every day.

The notion that you can name exactly zero symbols or exactly one symbol in the 'out()' "argument list", and if you name exactly one symbol then it gets (a copy of?) the returned value from the function which you can then use in your post-condition test strikes me as slightly more flexible at the cost of becoming slightly less obvious, and equally magical either way. But that's just my opinion, and I don't feel strongly about it.

-- Davidson

Reply via email to