From: budden on
Hi list!

I saw things like appendf in alexandria. (appendf a b)
can be replaced with (a sligtly more verbose, but more general)

(arg1f append a b), where

(defmacro arg1f (function place &rest args)
`(setf ,place (,function ,place ,@args)))

and, maybe,

(defmacro arg2f (function arg1 place &rest args)
`(setf ,place (,function ,arg1 ,place ,@args)))

Maybe there is a good traditional name for arg1f already?
From: Madhu on


* budden <9ffc6738-4b71-48e1-887f-1e100b094b73(a)k19g2000yqc.googlegroups.com> :
Wrote on Tue, 3 Nov 2009 02:26:38 -0800 (PST):

| (defmacro arg2f (function arg1 place &rest args)
| `(setf ,place (,function ,arg1 ,place ,@args)))
|
| Maybe there is a good traditional name for arg1f already?

[Without endorsing this style]

See C-h f callf and C-h f callf2
in an Emacs near you.

,---- callf is a Lisp macro in `cl-macs.el'.
|
| (callf FUNC PLACE ARGS...)
|
| Set PLACE to (FUNC PLACE ARGS...).
| FUNC should be an unquoted function name. PLACE may be a symbol,
| or any generalized variable allowed by `setf'.
`----

,---- callf2 is a Lisp macro in `cl-macs.el'.
|
| (callf2 FUNC ARG1 PLACE ARGS...)
|
| Set PLACE to (FUNC ARG1 PLACE ARGS...).
| Like `callf', but PLACE is the second argument of FUNC, not the first.
`----

--
Madhu
From: Nicolas Neuss on
Pascal Costanza <pc(a)p-cos.net> writes:

> _f is too cryptic, I think. What about 'modify-using?

_f refers to the suffix "f" occurring in several CL operators with
similar modifying behavior. So I think the name fits. And: since it
appears in "On Lisp", I guess that there will be quite some people
knowing it under this name.

Nicolas
From: budden on
Thanks all, I think _f satisfy me best as onLisp is an
important source of a tradition. It is a pity I didn't read
the book.

From: budden on
What about

(defmacro _2f (op arg1 place &rest args)
"Like _f, but place is a second argument of op"
(multiple-value-bind (vars forms var set access)
(get-setf-expansion place)
`(let* (,@(mapcar #'list vars forms)
(,(car var) (,op ,arg1 ,access ,@args)))
,set)))

?
 |  Next  |  Last
Pages: 1 2 3
Prev: lisp, java and evolution of types
Next: URGENT