phil at mobleybros dot com wrote:
> On Nov 29, 2004, at 1:09 PM, Mars Saxman wrote:
>> Operator_Convert does not apply. In the former case, you'd need
>> Operator_Add with an integer parameter; in the latter case, you'd need
>> Operator_AddRight with an integer parameter.
>
> So there is no implicit Operator_Convert?
No. Operator_Convert only applies when you assign a value to a variable,
pass a value as a parameter, or otherwise use a value in a context where a
specific datatype is expected.
> Is this something possible as a feature request, or would there be too
> many conflicts?
It never hurts to file a feature request. I did design it this way on
purpose, though: it eliminates ambiguity, avoiding a potential combinatorial
explosion of type-resolution possibilities. It would be possible to look for
a conversion operator anytime the compiler could not find the actual
operator, but I think it would be a bad idea.
> From what you are saying, in order for me to support Integer and Double
> conversion, I would need to have 5 methods for each math operator:
> Operator_Add(Rational), Operator_Add(Integer),
> Operator_AddRight(Integer), Operator_Add(Double) and
> Operator_AddRight(Double).
Yes, that's correct; you need to implement two methods per additional type
per operator you want your class to support.
> For the comparison operators, is there a Right/Left difference?
No; the same comparison operator works in either direction.
> Would I need to add lookup and negate?
You almost certainly don't need to implement the lookup operator for a class
like this. You should probably implement the negation operator if you're
going to implement subtraction, but it doesn't take any parameters, so you
only need one version (there is no reason for it to interact with any other
datatypes).
Mars Saxman
REAL Software
--
REAL World 2005 - The REALbasic User Conference
March 23rd - 25th, 2005, Austin, Texas
<http://www.realsoftware.com/realworld>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|