Closed mmontone closed 2 years ago
Hello,
I'm thinking that perhaps having local function aliases would be a good utility to have.
It may be just me perhaps, but I often like to bind large function names to shorter, locally, like this:
(flet-aliases ((-> json:encode-object-member)) (with-output-to-string (json:*json-output*) (json:with-object () (-> :id (vs::video-id video)) (-> :title (vs::title video)) (-> :status (vs::status video)))))
or this:
(flet-aliases ((-> access:accesses)) (list :id (-> video :id) :title (-> video :title) :description (-> video :description)))
This is my flet-aliases definition:
flet-aliases
(defmacro flet-aliases (bindings &body body) "Bind function aliases." `(flet ,(loop for binding in bindings collect `(,(first binding) (&rest args) (apply #',(second binding) args))) ,@body))
Do you think this is useful? Is there some other idiom for this? I have no idea if others are used to program like this.
Feel free to discard this :)
This can be done with fbind.
Oh great. Thanks.
Hello,
I'm thinking that perhaps having local function aliases would be a good utility to have.
It may be just me perhaps, but I often like to bind large function names to shorter, locally, like this:
or this:
This is my
flet-aliases
definition:Do you think this is useful? Is there some other idiom for this? I have no idea if others are used to program like this.
Feel free to discard this :)