CLOS slot and :type
I'm wondering what the :type in a CLOS object slot is actually used for, and if my using it for something else is going to end up causing a world of problems?https://github.com/massung/json
My JSON package for LW has a very helpful function: json-decode-into. You basically provide a class symbol and away it goes. For example:
(defclass login ()
((|username| :reader login-username)
(|password| :reader login-password)))
And now if you had the following JSON string:
{ "username" : "jeff", "password" : "12345" }
Then:
(json-decode-into 'login json-string) ;=> #<LOGIN>
Nothing terribly special here. However, often times there will be objects within objects. And, so I allow for a particular slot to use :type to identify when the JSON decoder should recurse:
(defclass account ()
((|login| :reader account-login :type login)
(|balance| :reader account-balance)))
With the above, calling (json-decode-into 'account ...), if a "login" key is found, it will recursively call (json-decode-into 'login ...) since that's the :type of the slot (and a subtype of standard-object).
I'm just curious if that - by doing this - I'm circumventing something else either in the standard or the LW implementation of CLOS?
Jeff M.