Okay, I understand. Thanks for the answer.
On Oct 29, 12:01 pm, "Graham Fawcett" <[EMAIL PROTECTED]>
wrote:
> On Wed, Oct 29, 2008 at 2:29 PM, samppi <[EMAIL PROTECTED]> wrote:
>
> > Is there a way to test an object if it's a certain kind of struct?
>
> > (defstruct person :name :age)
> > (def president (struct person "Sam" 30))
> > (struct? person president) ; true
>
> Hi,
>
> Defstruct doesn't define a new type in the OO sense. You can test for
> presence of keys, e.g.
>
> (every? #{:name :age} (keys president))
>
> will return true, because 'president' has both :name and :age keys.
> But other structures might also have these keys, so this is "duck
> typing" at best.
>
> Others have suggested using metadata to "tag" struct values with type
> information -- that might be an option you prefer over
> key-comparision.
>
> Best,
> Graham
>
>
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---