AccelerationNet / access

A common lisp library to unify access to common dictionary-like data-structures
Other
84 stars 12 forks source link

Allow setting non-string keys in hash tables #8

Closed anlsh closed 4 years ago

anlsh commented 4 years ago

I'm not sure why the current setf expander for access attempts to coerce the key to a string and fails if it can't. The behaviour is asymmetric with access:access, which will happily retrieve values associated with non-string keys.

bobbysmith007 commented 4 years ago

Hi, I appreciate you looking at this project and working with it. I have largely moved on from Common Lisp, and have not done any new lisp programming in a number of years.

While on the surface this seems sane and makes a lot of sense, I have code that may or may not rely on this behavior.

The idea behind this was that access was trying to make accessing hashtables, objects accessors and slot values, alist and plists all using the same interface. This was partially so I could have more flexibility in changing my storage as my needs changed without having to change my interface to it in every call site. Since objects cannot be keyed on other than symbols, I think this restriction was added to make the interface uniform. At the time it didn't make sense to try and unify all these (so that the storage was interchangable) but then allow keys that curtail that interchangeability.

This library was mostly written in a web context and I found that I was often looking things up from request values that came as strings from one side and lisp-sybmols from the other side of the code and that unifying those accessors made life easier. (EG we try to find by symbol and if we cant we search by symbol name). This patch also seems like it would interfere with that behavior.

All that is to say... I am not sure if it makes sense to merge this patch, though I am open to further discussion. I am also open to an interested person branching this library and taking ownership of and maintenance of it.

anlsh commented 4 years ago

Thanks for getting back, and with such a detailed explanation too :D

I understand your rationale both for starting the project and now the string-only access. It''s definitely best not to merge this patch if existing code relies on its behavior. Anyways, I've since found out that generic-cl:elt provides similar functionality to access. It's not quite as complete, but it solves most of my issues (specifically, it's missing the macros here and doesn't allow accessing slots- not a problem for me yet because I've never touched CLOS lol). I'll probably just stick with that for now