Re: elements vs sets



Date view Thread view Subject view Author view

Frank Finger (ff3@inf.tu-dresden.de)
Fri, 25 Feb 2000 13:36:36 +0100


Leonor Barroca wrote: > > Does this mean that I can always treat a set with a single element as the > element itself. I would interpret the application of collection operations to single elements not as an equivalence of one-element-sets and simple elements, but just as a helpful syntactic shortcut ("self.assoc->isEmpty" instead of "Set{self}->collect(assoc)->isEmpty"). > I have something of the form > let x = set1 -> intersection (set2) in > x.attribute = bla Since "x" is a Set, "x.attribute" is the shorthand form of "x->collect(attribute)" and therefore is a Bag. > If I know that the result of the intersection is always a set with a single > element can I treat the result of the intersection as the element itself and > talk about the properties of the element (as above)? If you know that the intersection has only one element then that should be part of the constraint. How about: let x = set1 -> intersection(set2) in x->size=1 and x->forAll(attribute=bla) I do not agree that there should be a special operator to get the only element of a Set, since I think that this is a very rare case and I wouldn't like to have the OCL type system complicated by such an operator. Regards, Frank


Date view Thread view Subject view Author view