Assign a unique name to the prototype object. Serialize instances as
map and put the reference to the prototype object under one of their
keys. Something like

{:prototype-components {:r10k {:resistance 10, :type :fixed, :unit :kΩ}}
 :components [{:name "resistor 1", :proto :r10k}, {:name "resistor 2",
:proto :r10k}]}

Jozef

On Sun, Aug 10, 2014 at 8:36 PM, MS <[email protected]> wrote:
> I'm trying to write an EE schematic capture program in clojure.  I'd like to
> be able to define a prototype component, say a resistor with value=10k, then
> be able to instantiate that many times, with each instance having an
> additional property such as a name string.  It's easy to ensure (identical?
> (proto instance1) (proto instance2)) returns true while in-memory, however
> I'm not sure how to write this out to disk.
>
> It seems the serialization libraries, print-dup, edn, etc., operate on
> values, so reading the database back in won't guarantee it's really the same
> object.  I'd like to have the thing defined *once* then instantiated many
> times, and have this captured in the on-disk version.
>
> Am I barking up the wrong tree?  ie, given immutable data structures,
> there's kind of no point in doing this.  I'm actually trying to save disk
> space, so I'd like to be able to refer in a few characters a potentially
> large structure that was defined earlier.  It would also be nice to have
> this be human readable.
>
> Would one of the JSON serializers do this for me?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to