On Tue, Dec 13, 2011 at 2:51 PM, Alan Malloy <a...@malloys.org> wrote:
> On Dec 13, 11:36 am, Stuart Sierra <the.stuart.sie...@gmail.com>
> wrote:
>> It's not clojure.walk, it's bean:
>>
>> user=> (empty (bean "hi"))
>> AbstractMethodError
>> clojure.lang.APersistentMap.empty()Lclojure/lang/IPersistentCollection;
>> clojure.core.proxy$clojure.lang.APersistentMap$0.empty (:-1)
>>
>> The generated class doesn't implement the 'empty' method.
>>
>> Please file a JIRA ticket, (and patch!)
>
> I don't think there is an obvious way to implement (empty b) for
> beans, since empty is supposed to return an empty collection of the
> same type. bean-maps are implemented as a snapshot-creating wrapper
> around a mutable underlying object, and if the object changes then so
> do new generated snapshots. So if you tried to make an empty one, its
> underlying object would still not be empty, and what would snapshots
> do then? You could make (empty b) just return {}, but that's a
> philosophical departure from how bean and empty generally behave so I
> don't think it's as easy as "this behavior is incorrect, please
> implement a fix".

Well, either

(clojure.walk/stringify-keys (bean "hi"))

is unreasonable, or else

user=> (clojure.walk/stringify-keys (bean "hi"))
AbstractMethodError
clojure.lang.APersistentMap.empty()Lclojure/lang/IPersistentCollection;
 clojure.core.proxy$clojure.lang.APersistentMap$0.empty (:-1)

is incorrect behavior. The former doesn't strike me as especially
plausible. Therefore if (empty some-bean) IS unreasonable,
stringify-keys should not be calling empty on its argument, or (less
likely) should be special-casing beans. (How to fix it is then left as
an exercise for the reader.)

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