To start off with, I agree with your comment about making Set the main type and making Bag an extension built upon that, as complex is built upon num, etc.

At 6:01 PM +0100 11/27/06, TSa wrote:
And I still think that it is a good idea
to name the set operations after their equivalent boolean connectives:

  (|) union
  (&) intersection
  (^) symmetric difference

Well, and to make them Bag operations to start with.

This may be a non-issue from a user's viewpoint, but as a user, I want set operations that have sets as input to return sets as output by default. Eg, unioning 2 Set that have common values should return a Set.

Moreover, since set operations would be a lot more common in practice than bag operations, the set operations should be the most terse, if they both aren't equally terse.

I see the matter as being similar to Int vs Num. Any operation whose operands are Ints should return Ints wherever it is conceivable to do so. In particular, this means that dividing an Int by an Int should return an Int. (Also, the modulus should be undefined for 2 Num.) Only promote an Int to a Num if one or more other operands are already Num, even if the value of that Num is a whole number.

So taking the semantics of Int vs Num that users see as examples for how Set vs Bag semantics should work, as far as argument and result types go, makes a lot of sense, and is easily to implement with Perl 6 multis.

-- Darren Duncan

Reply via email to