On 22.07.2008, at 09:43, Peter Gummer wrote:
> Jörgen Tegnér wrote:
>
>> Suppose most functions are made to return a result from a
>> calculation,
>> not just the default value. A warning would then be useful in
>> catching
>> errors in user code.
>
> A warning would be truly annoying, given that it is extremely common
> to leave Result at its default value.
Provided a function/object has a logically useful default value that
happens to match Eiffel's idea of a default value. The latter is
possibly
just practical for Eiffel's simplicity model.
> Each project would generate thousands of pointless warnings.
The Java approach is worth considering, too, IMHO: The compiler is
smart enough
to figure out that the local variable was uninitialised and cries
``error''
when no value was assigned before the variable is used.
The possible advantage of Java's approach is to prevent logic errors
caused by the
"academic habit" to leave out what is deemed "obvious".
Can't say I like this silent approach in a programming environment.
Programmer performed inference (of the initial value) may use up more
time spent
on "debugging the obvious" than a simple forced initialisation with
the logically
adequate default value.
>
> It used to drive me nuts: the compiler was smart enough to figure
> out that the local variable was uninitialised, but too stupid to
> initialise it to the default value appropriate for its type.
> Eiffel's approach is much simpler.
>
> - Peter
>
>
--
Georg Bauhaus +49 208 8821880
Y A Time Drain
http://www.9toX.de