Larry Wall wrote: > Michele Dondi wrote: > : Jonathan Lang wrote: > : > > If we want Sets in Perl, we should have proper Sets. > : > > : > I'll agree, depending on what you mean by "proper". I'd be > : > interested in having some means to perform set operations in perl6: > : > unions, intersections, differences, membership checks, and > : > subset/superset checks. > : > : Well, one point to look at the issue is that the keys of a hash > : already are a set. In some sense you get sets with an additional > : unavoidable feature (the values).
There are a couple of problems: first, a hash's keys are limited to strings; a set ought to be able to handle a wider range of data types. Second, the only set-related operation that hashes have implemented is the membership check. None of the other options I was looking for (see above) work without _considerable_ effort. Meanwhile, the proposal of a disjunction-derived Set class seems to cover all of these options with relative ease. That said: > I remember being rather happy when I discovered a use for the null > datatype in Ada. It turned out to be useful as a peg for hanging > various sorts of declarations on when you wanted to do something at a > particular point in the elaboration but didn't actually want to declare > something. We could have a similar situation here, where a Hash of > nothing doesn't actually have any values, just keys. Of course, it'd > be convenient if such hash values returned 1 as a default value, but > one could get along with just .exists. ...then you've got the notion of Fuzzy Logic Sets, where the key would be the prospective element and the value would be the degree of membership. For fuzzy sets, hashes seem to be a better fit than junctions, which have no obvious means of supplying the degree-of-membership info. You're still stuck with the "keys must be strings" problem, so it's not an ideal solution; but it's better than nothing. ===== Jonathan "Dataweaver" Lang __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com