<div>Ah, sorry, this was already answered! I'm cleaning my inbox and missed this email.<br></div><div><br></div><div class="protonmail_signature_block"><div class="protonmail_signature_block-user"><div>--<br></div><div>Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland<br></div><div>TurtleWare - Daniel Kochmański | <a href="http://www.turtleware.eu">www.turtleware.eu</a><br></div><div><br></div><div>"Be the change that you wish to see in the world." - Mahatma Gandhi<br></div><div><br></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br></div></div><div><br></div><div>‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br></div><div> On Sunday, January 10, 2021 4:13 PM, Paul Werkowski <pw@snoopy.qozzy.com> wrote:<br></div><div> <br></div><blockquote class="protonmail_quote" type="cite"><p>The context for my post was this:<br></p><div><span style="font-family:monospace">(define-presentation-to-command-translator
xlate-set-lcursor<br> (clim:blank-area com-set-cursor plotter <br> :documentation "Set Left Cursor"<br> :gesture :select<br> :tester ((object window)<br> (declare (ignore object))<br> (typep window 'basic-chart-pane)))<br> (object x y window)<br> (%set-a-cursor (chart-pane-chart window) 'lcursor x y window))<br> </span> </div><p>where originally I omitted 'object' from the next to last line
resulting in the wrong values being presented to the %set-a-cursor
function. User error on my part but LispWorks CLIM2 did what I
expected anyway thus keeping me ignorant of my omission. Perhaps
LW was able to infer what I wanted.<br></p><div class="moz-cite-prefix">On 1/10/2021 2:45 AM, Lauren P wrote:<br></div><blockquote type="cite"><div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Hey,<br></div><div dir="ltr"><br></div><div dir="ltr">On Sat, Jan 9, 2021, 11:21
Paul Werkowski <<a href="mailto:pw@snoopy.qozzy.com">pw@snoopy.qozzy.com</a>>
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div>(defun
make-translator-fun (args body)<br></div><div> (cond ((null args)<br></div><div> (warn "OBJECT parameter is obligatory (adding
ignored parameter)")<br></div><div> (let ((object-arg (gensym "OBJECT-ARG")))<br></div><div> `(lambda (,object-arg &key
&allow-other-keys)<br></div><div> (declare (ignore ,object-arg))<br></div><div> ,@body)))<br></div><div> (t<br></div><div> `(lambda (,(car args) &key ,@(cdr args)
&allow-other-keys)<br></div><div> (declare (ignorable ,(car args)))<br></div><div> ,@body))))<br></div><div> <br></div><div> I guess the above does the right thing if ARGS is NIL but
won't catch <br></div><div> the case of ARGS incorrectly given as, for instance, (x y
window) <br></div><div> instead of (object x y window).<br></div></blockquote></div></div><div dir="auto">I would give it an explicit parameter so it
takes (OBJECT-ARG ARGS BODY) so autodoc shows where the object
argument goes without having to remember to read the
docstring.<br></div><div dir="auto"><br></div><div dir="auto">I'd put in a destructuring bind at the T case
and then test that... it should bomb in the compiler if you
pass it (NIL X Y WINDOW) as-is: you'll need to gensym and
DECLARE IGNORE if it's a NIL.<br></div><div dir="auto"><br></div><div dir="auto">If you wrap it in a macro the way I write that
lambda list is ((OBJECT-ARG &REST ARGS) &BODY BODY);
it is displayed by autodoc and the destructuring bind catches
it at compile time. If you really want to accept a no
arguments form, I tend to use NAME* for the alternative form
and make it a wrapper stub, otherwise I prefer to assume
"forgot arguments" and error.<br></div><div dir="auto"><br></div><div dir="auto">I wouldn't set the object argument ignorable in
the T case unless it was typed in as NIL, as it can hide bugs
in the body code. Better to let the user specify ignorable in
the BODY if they are sure they don't need it.<br></div><div dir="auto"><br></div><div dir="auto">(More of a style thing, I find it cleaner to
normalize the argument list to replace the empty list with
(NIL) so it works with destructuring bind: you can get rid of
the main branch and only type the bulk of the code once, since
you need to check for a gensym and ignore declaration in the T
case as well. Also, leave out &ALLOW-OTHER-KEYS unless
absolutely necessary... I've found it makes it exceedingly
difficult to catch typos.)<br></div><div dir="auto"><br></div><div dir="auto">Hope this is useful for you!<br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote></div></div></div></blockquote></blockquote>