If Moto had Operator Overloading ...
David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Fri, 14 Mar 2003 10:54:04 -0500
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Message-ID | <[email protected]> |
If Moto were to support Operator Overloading (which at this point would be fairly easy to implement) what operations (on what Objects) would we want to overload initially ? I've put together a list of some of the operations that pop out at me as being good candidates. I figure the C++ STL will be a good guide here. Note that for the starred (*) functions it seems to me that the performance / memory usage costs involved in cloning the containers make them real silly operations under most circumstances Stringset +(Stringset,Stringset) - Returns a new Stringset that is the union of the two Stringsets Stringset +=(Stringset,Stringset) - Returns the original (or a new one?) Stringset with elements from the second Stringset added to it. Stringset -(Stringset,Stringset) - Returns a new Stringset that is the first Stringset with the elements common to both Stringsets removed Stringset -=(Stringset,Stringset) - Returns the original (or a new one?) Stringset with the elements common to both Stringsets removed * Stringset +(Stringset,String) - Returns a new Stringset that adds the String to the Stringset * Stringset +=(Stringset,String) - Returns a original (or a new one?) Stringset that adds the String to the Stringset * Stringset +(String,Stringset) - Returns a new Stringset that adds the String to the Stringset * Stringset -(Stringset,String) - Returns a new Stringset that removes the String from the original Stringset * Stringset -=(Stringset,String) - Returns a original (or a new one?) that removes the String from the original Stringset boolean eq(Stringset,Stringset) - Returns true iff the Stringsets contain the same Strings boolean ne(Stringset,Stringset) - Returns false iff the Stringsets contain the same Strings Intset +(Intset,Intset) - Returns a new Intset that is the union of the two Intsets Intset +=(Intset,Intset) - Returns the original (or a new one?) Intset with elements from the second Intset added to it. Intset -(Stringset,Stringset) - Returns a new Intset that is the first Intset with the elements common to both Intsets removed Intset -=(Intset,Intset) - Returns the original (or a new one?) Intset with the elements common to both Intsets removed * Intset +(Intset,int) - Returns a new Intset that adds the int to the Intset * Intset +=(Intset,int) - Returns a original (or a new one?) Intset that adds the int to the Intset * Intset +(int,Intset) - Returns a new Intset that adds the int to the Intset * Intset -(Intset,int) - Returns a new Intset that removes the int from the Intset * IntSet -=(IntSet,int) - Returns a original (or a new one?) that removes the int from the original IntSet boolean eq(Stringset,Stringset) - Returns true iff the Intsets contain the same ints boolean ne(Stringset,Stringset) - Returns false iff the Intsets contain the same ints Vector +(Vector,Vector) - Returns a new Vector that appends the contents of second vector to the first * Vector +(Vector,Object) - Returns a new Vector that adds the Object on the end of the original Vector * Vector +(Object,Vector) - Returns a new Vector that adds the Object on the start of the original Vector Object Vector::[](int) - Returns the element at the index provided Object Vector::[]=(int,Object) - Sets the element at the index provided boolean eq(Vector,Vector) - Returns true iff the Vectors contain the same elements in the same order (how do we compare element equality?) boolean ne(Vector,Vector) - Returns false iff the Vectors contain the same elements in the same order (how do we compare element equality?) SymbolTable +(SymbolTable,SymbolTable) - Returns a new SymbolTable that is the union of the two SymbolTables (What do we do about common key/value pairs ?) SymbolTable +=(SymbolTable,SymbolTable) - Returns the original (or a new one?) SymbolTable with elements from the second SymbolTable added to it. (What do we do about common key/value pairs ?) SymbolTable -(SymbolTable,SymbolTable) - Returns a new SymbolTable that is the first SymbolTable with the elements common to both SymbolTables removed (What do we do about common key/value pairs ?) SymbolTable -=(SymbolTable,SymbolTable) - Returns the original (or a new one?) SymbolTable with the elements common to both SymbolTables removed (What do we do about common key/value pairs ?) boolean eq(SymbolTable,SymbolTable) - Returns true iff the Symboltables contain the same key value pairs (for values how do we compare equality ? ) boolean ne(SymbolTable,SymbolTable) - Returns false iff the Symboltables contain the same key value pairs (for values how do we compare equality ? ) Object SymbolTable::[](String) - Returns the Object associated with the key provided Object SymbolTable::[]=(String,Object) - Sets the Object associated with the key provided IntHashtable +(IntHashtable,IntHashtable) - Returns a new IntHashtable that is the union of the two IntHashtables (What do we do about common key/value pairs ?) IntHashtable +=(IntHashtable,IntHashtable) - Returns the original (or a new one?) IntHashtable with elements from the second IntHashtable added to it. (What do we do about common key/value pairs ?) IntHashtable -(IntHashtable,IntHashtable) - Returns a new IntHashtable that is the first IntHashtable with the elements common to both IntHashtables removed (What do we do about common key/value pairs ?) IntHashtable -=(IntHashtable,IntHashtable) - Returns the original (or a new one?) IntHashtable with the elements common to both IntHashtables removed (What do we do about common key/value pairs ?) boolean eq(IntHashtable,IntHashtable) - Returns true iff the IntHashtables contain the same key value pairs (for values how do we compare equality ? ) boolean ne(IntHashtable,IntHashtable) - Returns false iff the IntHashtables contain the same key value pairs (for values how do we compare equality ? ) Object IntHashTable::[](int) - Returns the Object associated with the key provided Object IntHashTable::[]=(int,Object) - Sets the Object associated with the key provided Object ResultSet::[](int) - Returns the Object (???) at the column index of the current row provided ? Object ResultSet::[](String) - Returns the Object (???) at the named column of the current row provided ? void ResultSet::++ - Equivalent to rset.next(); void ResultSet::-- - Equivalent to rset.prev(); Array +(Array,Array) - Returns a new Array that appends the contents of second vector to the first Function +(Function,Function) - Do a google search on 'Delegate composition in C#' ... would this be useful ?