I'm pretty sure Clojure already does this, because of the built in
equality by value.  I'm pretty sure the hash keys work of off the
value, too.

Do you have any code you could post to github or something?  That
would help us determine if such a thing already exisits.  I know this
doesn't save you the pain of writing the library, but it could save
you the trouble of maintaining it in the future.

However, writing this library could be a very cool educational
exercise.  That, and I could have missed your intent entirely.

Good luck
Sean

On Jun 29, 6:09 am, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> Dear all,
>
> I am coding a (very) small hash consing library for clojure.
>
> For those we don't happen to know what hash consing is, it is a way of
> allowing equal data structures to be shared in memory.
> This leverages the purity (as in "immutability") of data structures to
> reduce memory footprint (no duplication of data for just a constant
> overhead per allocation) and makes hashing and equality tests faster.
> (You can use java non overloaded hashCode, and == to test equality,
> because of the sharing. So both operations are O(1), with a very small
> constant, whatever is the complexity of the hash consed data
> structures.)
> This can then be used, in combination with referential transparency to
> make memoized function faster.
>
> I have a java file and a clojure interface that seem to work, at least
> on my example. I plan to put something somewhere someday, but before
> spending too much time in making this releasable, i Have a few
> questions:
>
> - does something already exists in contrib that I have missed?
> - is someone else working on that?
> - are there any "features that I need and that you must implement" that
> you think of?
>
> My current plans are:
> - using a java concurrent hash map to soft referenced objects for the
> hash consing table.
> - only two fields in an hash consed object: the value it represents,
>   and a generic field called "cached_data" used to store anything you
> want to memoize about this data structure. (Keeping this cached data a
> bit longer is the reason I plan to use soft references and not weak
> references)
>
> I am not a clojure expert and I am not a java coder at all, so don't
> hesitate to tell me if my plans are somehow wrong.
>
> Bets regards,
>
> Nicolas.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to