On Mon, Sep 14, 2020 at 01:11:34AM -0700, Tony Garnock-Jones wrote: > On Sunday, September 13, 2020 at 12:41:15 AM UTC+2 hen...@topoi.pooq.com > wrote: > > > True, but that would require rewriting list, and quasiquote, ans > > others like that to use the hashcons. > > > > Not impossible. > > > > One potentially useful trick is to write a function `canonicalize` which > deeply traverses the structure of its argument, rebuilding it if necessary > to produce the canonical representative for each piece of substructure. > Then you can `(canonicalize (map f xs))` without having to rewrite `map`, > and it takes (asymptotically) the same time as it would if you did alter > `map`. > > Another thing to watch out for is that hashconsing via `equal?` can be > quite expensive for things like hash tables. I used hashconsing extensively > in the first implementation of Syndicate and ended up having to implement > my own treaps to get good asymptotic performance with a hashconsed > dictionary structure.
I would, ideally, only use hashcons on those cons-cells which had themselves been hashconsed, so eq? would suffice. -- hendrik -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/20200914121810.vsbo56odmxf7r4f6%40topoi.pooq.com.