rutils icon indicating copy to clipboard operation
rutils copied to clipboard

Possible improvement to generic-elt on objects

Open jasom opened this issue 9 years ago • 3 comments

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)

jasom avatar Jun 04 '16 05:06 jasom

Yes, this sounds reasonable. I'll add this in the next update. Also, patches are welcome :)

vseloved avatar Jun 04 '16 06:06 vseloved

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.

jcguu95 avatar Apr 29 '24 15:04 jcguu95

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

jasom avatar Aug 23 '24 19:08 jasom