Chuck wrote:Yeah, operator overloading is definitely in the plans. Just haven't gotten there yet.
Sets are not immutable. Try this:
class X
def main is shared
s = {1, 2, 3}
assert 2 in s
assert s.count == 3
s.add(4)
assert 4 in s
assert s.count == 4
print s
It's the objects that you put in sets (or use a dictionary keys) that need to be immutable. Actually, it just needs to be the case that mutating the objects does not change their .equals and .getHashCode behavior. This is a general computing requirement, not specific to Cobra.
Now for my question: Your user id is jonathandavid, but your name is Manuel. How come? (Just curious.)
-Chuck
OK, so I can put objects of any class in a set, but I should not modify them once they're there, unless that would not change their .equal & .getHashCode. It's the same in C++ not that I think about it, I just thought that Cobra was actually enforcing this (as in refusing to compile if I tried to create a sef of a mutable class).
As for the operator overloading thing, have you considered trying to make them work as in the Scala programming language? Their approach is really nice, although maybe it wouldn't fit with the structure of Cobra.
Oh, my name is definitely Manuel, I just use the nick jonathandavid sometimes because I think it sounds cool (it does to me, anyway). It's not a name I made up, it's actually a song by british band belle and sebastian. Not the most terribly interesting information, but since you were asking...
Regards,
Manuel