I'm trying to develop a library for structs (hopefully will be
generally useful), with an API parallel to the struct API. One of the
capabilities I would like to have is \typed \structs, i.e., if you
attempt to assoc something of the wrong type to a field, it throws an
error. (I can't find anything like this in Clojure now; type
annotations would not be appropriate, right?). Any suggestions on
syntax/functionality?
I was going to do something like this: a struct field declaration
is a vector, with the first element containing a "type prototype",
e.g. (typed-defstruct test-struct [1 :a] ["asdf" :b] [:blank :c]),
showing that field :a is an int, :b is a string, :c is a keyword. On
the other hand maybe one should just declare the type, so that you
could specify something in the numerical tower (e.g. "Number" as
opposed to "Int"). Thoughts?
Thanks,
Nick.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---