Re: Overloading (CVS commit) - Relationals implemented
David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Mon, 28 Apr 2003 21:09:00 -0400
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Message-ID | <[email protected]> |
You are moving this feature along! Very cool! I've been meaning to get some opinions on relational operator overloading of equality (and inequality etc...). In Java (and C++ when not specifically overloaded I guess) the == operator is a plain old pointer comparison. In java when you want to compare the content of two strings you say: string1.equals(string2) kinda wordy I know, that's why in moto we have eq for this string1 eq string2 and we also have lt,gt,lte,and gte for the rest of the string equality comparisons. The reason I didn't overload == for strings when coding conditionals originally is that I felt there was value in always being able to test pointer equality of two objects with == since there are cases where you want to verify you have the same instance of an object (as opposed to an equivalent object). So I'm wondering now if we want to make == overloadable at all since its default behavior is applicable to all objects by default, and instead offer overloading only of the 'eq' operator and the other string comparison operators so they really become 'programmatic object comparison operators' On Saturday, April 26, 2003, at 10:12 AM, Stefano Corsi wrote: > - moved motox_try_overloaded_binary_op to > motox_try_overloaded_method_op in > motox.c > - created motox_try_overloaded_function_op > - moved motov_fillArgs to motox.c > - changed static storage to non static for motoi_callEDF and > motoi_callMDF in > motox (to permit call from inside motox.c). Prototypes in motoi.h. > - implemented iset_comp2 in intset_op.c (for comparing with size). > - implemented iset_equal iset_notequal iset_gt iset_lt in intset_op.c What does iset1 < iset2 mean ? Is it based on the size of the sets ? > - added operators to IntSet.i > - changed over_intset.moto in tests > > Adding relational was smooth! > That's how you know your implementation is the right one :) everything just starts falling into place! > Stefano > -Dave