On 24 April 2010 05:48, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> Ideally, I'd like to see a way to allow me to write a program using
> (:name employee), and later, if I need to, customize the employee
> datatype so that (:name employee) actually dispatches to some other
> function.  Ditto with (assoc employee :name "Mark") (for example, to
> validate the data in some way?).

You can do that with deftype by implementing the appropriate
interfaces, like Rich mentioned in response to Konrad above. I've been
playing around with this actually:

http://gist.github.com/377480

Note that (:x (Foo. 1 2 3) nil) returns 1, while ((Foo. 1 2 3) :x)
returns 2. (It could be the other way around or whatever, anything
seems possible.)

Also note that for some reason (:x (Foo. 1 2 3) nil) works fine, while
(:x (Foo. 1 2 3)) throws an exception; not sure if I've run into a bug
here or simply done something silly (I'd expect the latter though).

Sincerely,
Michał

-- 
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