[proposal] unification: ref for arrays
Posted: Mon Dec 02, 2013 8:41 pm
Regarding refs, lists and arrays behave similar, but not the same.
There seems to be a possibility for further unification.
This works for both:
But getting a ref does only work for lists (see above); this does not work:
What about having refs for arrays, too?
Then this would work, too:
The semantics of an array ref could/should be the same as for list refs.
Such unification would be good for functions operating on containers - being agnostic against the array/list difference.
Because there already is setf for arrays, I'm assuming that most machinery to get this done already exists.
There seems to be a possibility for further unification.
This works for both:
Code: Select all
(setq l (sequence 1 10)
a (array 10 l))
;;
;; Applying refs works for both lists and arrays:
(setq r (ref 5 l))
(l r)
(a r)
Code: Select all
> (ref 5 a)
ERR: list expected in function ref : (1 2 3 4 5 6 7 8 9 10)
Then this would work, too:
Code: Select all
(setq r (ref 5 a))
(l r)
(a r)
Such unification would be good for functions operating on containers - being agnostic against the array/list difference.
Because there already is setf for arrays, I'm assuming that most machinery to get this done already exists.