[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Backquote idioms



    Date: Wed, 22 May 85 12:04 EDT
    From: Bernard S. Greenberg <BSG@SCRC-STONY-BROOK.ARPA>

	Date: Wed, 22 May 85 11:54 EDT
	From: David C. Plummer in disguise <DCP@SCRC-QUABBIN.ARPA>

	    Date: Wednesday, 22 May 1985, 10:56-EDT
	    From: Guy Steele <gls%AQUINAS@THINK.ARPA>

	    ```(,@',,@q)				;Alan's example
		...etc...
	    (QUOTE (3 5) (4 6))
	    <error>		;but would be sensible if Q were the singleton list (R),
				; in which case third evaluation would produce (3 5).

	    Do you all believe these?

	Does it matter?  RWK said he has never used a triple backquote.  Neither
	have I.  There may be applications which are really good hacks, but can
	they be maintained?  Even some double nested backquotes require enough
	though that they should probably be avoided.  Conciseness and
	compactness does not imply clarity and robustness.

    From LMFS:DEFSTORAGE (part of PL/I record simulating substrate of File System):

    (defmacro once-onlify-index-offset (form)
      (let ((do-it-p (gensym))
	    (was-ixo (gensym))
	    (ggs (gensym)))
	`(let ((,do-it-p (not (atom *defstorage-index-offset*)))
	       (,was-ixo *defstorage-index-offset*))
	   (let-if ,do-it-p				;Guaranteed needs wrapping now.
		   ((*defstorage-index-offset* '',ggs))
	     (wrap-if (symbolp ,was-ixo)		;Needs once-onlying at macro time.
		      `(once-only (,,was-ixo) ,:the-form)
		      (wrap-if ,do-it-p
			       ``(let ((,',',ggs ,,,was-ixo)) ,,:the-form)
			       ,form))))))

    Admittedly, now that there are "language tools", this can be done better.

I would not want to maintain this, especially the line
			       ``(let ((,',',ggs ,,,was-ixo)) ,,:the-form)
Is that ,,, really correct, or are you using the fact that NIL and T are
self evaluating?  If you have to think about that for more than 10
seconds, something is wrong.  If it is obvious to you, I commend you for
your understanding of complex uses of backquote, and ask you to take
pity on the rest of us.  

I'll contend it can be done better without language tools.  For example,
you could build the form from the inside out, instead of your outside in
method.  Something like (I'm not sure what the semantics of :the-form
are, so I'll guess),
    (defmacro once-onlify-index-offset (form)
      (let ((do-it-p (gensym))
	    (was-ixo (gensym))
	    (ggs (gensym)))
	`(let ((,do-it-p (not (atom *defstorage-index-offset*)))
	       (,was-ixo *defstorage-index-offset*))
	   (let-if ,do-it-p ((*defstorage-index-offset* '',ggs))
	     (setq form (wrap-if ,do-it-p
				 `(let ((,',ggs ,,was-ixo)) ,:the-form)
				 form))
	     (setq form (wrap-if (symbolp ,was-ixo)
				 `(once-only (,,was-ixo) ,:the-form)
				 form))
	     form))))
I also have personal problems with macros that do computation instead of
translation.

    Also, idioms like

      `',
    and the like should be discussed.  I have always been amused by
    the analogy to tensor subscripts and superscripts and their
    contraction rules.