Hi Nicolas,

2015ko urriak 29an, Nicolas Goaziou-ek idatzi zuen:
> Could these 2 use cases be refactored?
> 
>   (mapcar #'cdr (org-babel-get-header params :var))
> 
> is not very far (but stlightly different) from
> 
>   (cadr (org-babel-get-header params :colname-names))
> 
> when there is a single association in PARAMS. Otherwise, it is up to the
> user to know that there can be multiple :var keys but only
> one :column-names.

But users know that anyway, since it’s implied by the semantics of
:colname-names.  Actually the most typical way of accessing the value
of :colname-names in the code is (cdr (assoc :colname-names params))
(~20 uses, which ought to use assq instead); using o-b-get-header for
:colname-names is an exception.

The issue is that o-b-g-h gives an API for accessing key-values in a
1:many mapping.  But :var is the only key that can actually be 1:many.
All other keys are singletons, and can be handled through the usual
emacs API for 1:1 mappings (assq and friends) – and in the existing
codebase they often are.  If we provide an API within babel, we should
make it as specific as possible.

(OTOH if we provide 1:many mapping access, we should name it
org-assq-multiple or something like that.  But it’s unnecessary in this
case.)

-- 
Aaron Ecay

Reply via email to