On Mon, Feb 21, 2005 at 03:07:34PM +0100, Michele Dondi wrote: : On Sun, 13 Feb 2005, 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 alread are : a set. In some sense you get sets with an additional unavoidable feature : (the values). : : Talking Perl6, which has a type system, it becomes suddenly possible to : have hashes of whatever type of values one may want. For example one may : implement a good approximation to a set with an hash of 1-bit integers; I : don't know if there will be a built in one-value-only data type, and I : wouldn't see for it any other use than this.
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. But instead of defining a nothing type, we could just continue down the road we started in A12 that says an enumerated value is simply a subtype that happens to be constrained to a single value. In which case you could just declare a Hash of bool::true or a Hash of Days::Tuesday and the hash would always just return that value (but only for existing keys, of course). And then nothing is stopping you from defining nothing explicitly. Larry