rutils
rutils copied to clipboard
Possible improvement to generic-elt on objects
From your blog post:
Still, one issue remains unsolved in this approach: the preferred Lisp slot-access method is not via slot-value, but with an accessor method that is exported
given that the preferred method is with an accessor, why not allow something like:
(? obj #'accessor-fn)
Yes, this sounds reasonable. I'll add this in the next update. Also, patches are welcome :)
Unfortunately, I think this is not possible unless we break API. One counter example is
(let ((accessor (lambda (ht) (gethash :a ht))))
(? #h(accessor 0 :a 1) accessor))
If the it works in the new semantics, it should return 1. However, in the old semantics it returns 0.
I suggest to close this issue.
I totally spaced on this, but wouldn't this be solved by requiring it to be a cl:function form as it was in my initial comment? It does mean there's no dynamic dispatch on accessors though...