Re: Method overrides and covariant return types
Isaac Gouy <[email protected]> Fri, 5 Mar 2004 19:35:24 -0800 (PST)
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
> The redundancy of the type is not even useful, since it is already
> embodied in the code implementing the method.
I disagree. In languages without explicit type information the one
thing that everyone adds, as a comment, is the return type.
As the method definition can be in one file, and the method
implementations are spread across other files, it would certainly be
useful to show the return type in each place.
And it's unclear to me why it should be an error to do so:
int fact(0) = 1;
Encountered "0".
Was expecting one of:
"(" ...
")" ...
"?" ...
"!" ...
"alike" ...
<IDENT> ...
> int fact(int n) requires n>=0;
> fact(0) = 1;
> fact(n) = n * fact(n - 1);
Perhaps it would be useful to consider an example where the parameter
type actually allowed extension?
(We aren't able to subclass int, which makes it difficult to understand
what situations might arise with value dispatch.)
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click