<div dir="ltr">If we do go this way, we should be careful about the subtyping relationship since we want a predicate that means "will not be mutated and I can rely on that to reason about my library's behavior" and if mutable sets are a sub-thing of immutable ones, we might lose that (depending on how things are set up).<div>
<br></div><div>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 2, 2013 at 2:57 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com" target="_blank">jay.mccarthy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No. Mutable sets would implement gen:set and then just have a few more<br>
methods in the gen:mset interface. Structs can implement any number of<br>
generics.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jay<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Oct 2, 2013 at 1:31 PM, J. Ian Johnson <<a href="mailto:ianj@ccs.neu.edu">ianj@ccs.neu.edu</a>> wrote:<br>
> This means I can't interchange between mutable and immutable sets for my functions that only need to read generic sets, unless we further subdivide and have gen:set-query gen:set-constructor gen:set-mconstruct.<br>

><br>
> -Ian<br>
> ----- Original Message -----<br>
> From: "Jay McCarthy" <<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>><br>
> To: "Carl Eastlund" <<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>><br>
> Cc: "Racket Developers" <<a href="mailto:dev@racket-lang.org">dev@racket-lang.org</a>><br>
> Sent: Wednesday, October 2, 2013 3:23:07 PM GMT -05:00 US/Canada Eastern<br>
> Subject: Re: [racket-dev] Generics updates<br>
><br>
> Regarding a point from RacketCon, I don't like that gen:set includes<br>
> functions like set-add! and set-remove!. I think that sets with<br>
> mutations are subclass of get:set and we should have a separate<br>
> gen:mset (or something) interface for mutable versions.<br>
><br>
> I dislike that an obvious implementation of sets, hash tables, are not<br>
> sets to gen:set, because there are operations that cannot be performed<br>
> on them.<br>
><br>
> I think that "X implements generic G" should imply "All functions of G<br>
> work on X". But this is not the case with gen:set and hasheq sets, for<br>
> instance.<br>
><br>
> Jay<br>
><br>
><br>
> On Tue, Jul 23, 2013 at 9:37 AM, Carl Eastlund <<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>> wrote:<br>
>> My work on adding gen:set, and related changes to define-generics and<br>
>> gen:dict, is ready for review and (hopefully) to push to the master branch.<br>
>> The branch moved in the process of cleaning things up, it's now at:<br>
>><br>
>>   <a href="https://github.com/carl-eastlund/racket/tree/generics-from-scratch" target="_blank">https://github.com/carl-eastlund/racket/tree/generics-from-scratch</a><br>
>><br>
>> (The "from scratch" just refers to the process of rebuilding the git<br>
>> history, I didn't go out of my way to rewrite anything in the code base from<br>
>> scratch, although in some places a lot of code did move around.)<br>
>><br>
>> What's new in the branch:<br>
>><br>
>> - Generics now support a few new options<br>
>>   - #:fallbacks specifies fallback method implementations for instances with<br>
>> no implementation<br>
>>   - #:fast-defaults specifies instances on a "fast path", useful for<br>
>> built-in types<br>
>>   - #:defined-predicate gives a more intuitive and efficient interface than<br>
>> #:defined-table<br>
>>   - #:derive-property allows generics to piggy-back on existing struct<br>
>> properties<br>
>><br>
>> - Sets are now a generic datatype through gen:set<br>
>>   - lists are now sets<br>
>>   - the built-in set types are now documented as "hash sets"<br>
>>   - there are mutable and weak hash sets<br>
>>   - you can define new set types quickly with define-custom-set-types<br>
>>   - most set operations are now methods with fallbacks<br>
>>   - sets now support -copy and -clear operations, plus mutating [!] versions<br>
>> of operations<br>
>><br>
>> - Dictionaries have a few changes<br>
>>   - new macro define-custom-hash-types [*]<br>
>>   - most dict operations are now methods with fallbacks<br>
>>   - dicts now support -copy, -clear, -clear!, and -empty? operations<br>
>><br>
>> I've run some benchmarks and performance of the various generic operations<br>
>> are comparable to the current HEAD, so there should be no major performance<br>
>> changes with this patch.<br>
>><br>
>> [*] I've added define-custom-hash-types and define-custom-set-types rather<br>
>> than just adding make-custom-set akin to make-custom-hash because<br>
>> make-custom-hash is hard to use.  The documented behavior -- that any custom<br>
>> hash is equal to any other created with the same bindings and predicates /<br>
>> hash functions -- was never true and can be expensive or at least tricky to<br>
>> implement.  It seemed more sensible to just remove the erroneous<br>
>> documentation on make-custom-hash, and add the definition form to create<br>
>> constructors for new, explicitly-compatible dict and set types.  Both<br>
>> definition forms bind predicates and constructors for new (set or dict)<br>
>> types with immutable, mutable, and weak variants that inter-operate.<br>
>><br>
>> If there are no serious issues brought up in the next day or two, I'll push<br>
>> it to the development branch, since our current release process isn't<br>
>> following HEAD.<br>
>><br>
>> Carl Eastlund<br>
>><br>
>> _________________________<br>
>>   Racket Developers list:<br>
>>   <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
> Assistant Professor / Brigham Young University<br>
> <a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
><br>
> "The glory of God is Intelligence" - D&C 93<br>
> _________________________<br>
>   Racket Developers list:<br>
>   <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
<br>
<br>
<br>
--<br>
Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
_________________________<br>
  Racket Developers list:<br>
  <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</div></div></blockquote></div><br></div>