[nem-bug] [Nemerle 0000759]: multiple type conversion operators

feedback at nemerle.org feedback at nemerle.org
Sat Sep 23 10:19:25 CEST 2006


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=759> 
======================================================================
Reported By:                aleksey
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   759
Category:                   Compiler
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             09-21-2006 00:36 CEST
Last Modified:              09-23-2006 10:19 CEST
======================================================================
Summary:                    multiple type conversion operators
Description: 
C# allows multiple implicit or explicit cast operators to be defined.
ncc however doesn't treat cast operators as a special case and reports
with "attempted return type overload" error, though it works fine with
several conversions defined in externally referenced types.

I am not sure whether this is by design or something else. It was easy to
tweak compiler a little and add this feature. I've included a patch,
though I am not sure it is the most elegant and correct solution(at least
it seems to work). Patch also enables return type overloading, by
replacing error message with warning, so you probably would not like to
apply it as is. Btw, am I right that prohibiting return type overloads was
a design decicion, not a limitation(as it seems to work pretty fine)?
======================================================================

----------------------------------------------------------------------
 malekith - 09-23-06 09:58 
----------------------------------------------------------------------
The right way to do it, would be to special-case cast operator and not to
issue error message in this case.

As for the general return type overloading -- it was a design decision.
There are two reasons. The first one is that CLS doesn't allow that (so no
other language could use such functions). The second one is that type
inference will have a much harder time guessing the right types in
presence of return type overloads. Also at the time the decision was made,
the type inference algorithm was much weaker than it is now.

----------------------------------------------------------------------
 aleksey - 09-23-06 10:19 
----------------------------------------------------------------------
Well, that's what my patch is doing. Just replace warning with error
message in my code, so return type overloading will not work(I enabled it
just for experimentation purposes) and cast operators will be a
special-case and thus will not issue error message.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
09-21-06 00:36 aleksey        New Issue                                    
09-21-06 00:36 aleksey        File Added: multiple_cast_operators.patch         
          
09-23-06 09:58 malekith       Note Added: 0001452                          
09-23-06 10:19 aleksey        Note Added: 0001453                          
======================================================================




More information about the bugs mailing list