<div dir="ltr"><div><div><div><div><div><div><div><div>My work on adding gen:set, and related changes to define-generics and gen:dict, is ready for review and (hopefully) to push to the master branch. 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">https://github.com/carl-eastlund/racket/tree/generics-from-scratch</a><br><br></div>(The "from scratch" just refers to the process of rebuilding the git history, I didn't go out of my way to rewrite anything in the code base from scratch, although in some places a lot of code did move around.)<br>
<br></div>What's new in the branch:<br><br></div><div>- Generics now support a few new options<br></div><div> - #:fallbacks specifies fallback method implementations for instances with no implementation<br></div><div>
- #:fast-defaults specifies instances on a "fast path", useful for built-in types<br></div><div> - #:defined-predicate gives a more intuitive and efficient interface than #:defined-table<br></div><div> - #:derive-property allows generics to piggy-back on existing struct properties<br>
</div><div><br></div>- Sets are now a generic datatype through gen:set<br></div><div> - lists are now sets<br> - the built-in set types are now documented as "hash sets"<br></div> - there are mutable and weak hash sets<br>
</div></div> - you can define new set types quickly with define-custom-set-types<br></div> - most set operations are now methods with fallbacks<br></div><div> - sets now support -copy and -clear operations, plus mutating [!] versions of operations<br>
</div><br><div>- Dictionaries have a few changes<br></div><div> - new macro define-custom-hash-types [*]<br></div> - most dict operations are now methods with fallbacks<br><div> - dicts now support -copy, -clear, -clear!, and -empty? operations<br>
<br></div><div>I've run some benchmarks and performance of the various generic operations are comparable to the current HEAD, so there should be no major performance changes with this patch.<br><br></div><div>[*] I've added define-custom-hash-types and define-custom-set-types rather than just adding make-custom-set akin to make-custom-hash because make-custom-hash is hard to use. The documented behavior -- that any custom hash is equal to any other created with the same bindings and predicates / hash functions -- was never true and can be expensive or at least tricky to implement. It seemed more sensible to just remove the erroneous documentation on make-custom-hash, and add the definition form to create constructors for new, explicitly-compatible dict and set types. Both definition forms bind predicates and constructors for new (set or dict) types with immutable, mutable, and weak variants that inter-operate.<br>
<br></div><div>If there are no serious issues brought up in the next day or two, I'll push it to the development branch, since our current release process isn't following HEAD.<br></div><div><div><div><div><div><div>
<div><br><div><div><div>Carl Eastlund</div>
</div></div></div></div></div></div></div></div></div></div>