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

quasiquote limit cases



   From: "Guillermo J. Rozas" <gjr@martigny.ai.mit.edu>
   Date: Mon, 23 Mar 1998 12:34:05 -0500
   Reply-To: gjr@martigny.ai.mit.edu

   |   Subject: Re: quasiquote limit cases
   |   From: Jim Blandy <jimb@red-bean.com>
   |   Date: 22 Mar 1998 21:20:57 -0500
   |   
   |   
   |   >    R5RS says:
   |   >      ... If no commas appear within the <template>, the result of
   |   >      evaluating `<template> is equivalent to the result of evaluating
   |   >      '<template>.
   |   
   |   The intent was clear to me, but I think this is misleading because it
   |   says that the *results* are equivalent; the results are values, and
   |   thus it's reasonable to wonder about which definition of value
   |   equivalence the authors meant.
   |   
   |   I suggest:
   |   
   |       If no commas appear within the <template>, the expression
   |       `<template> is equivalent to the expression '<template>.
   |   
   |   It's shorter, and it's clear that one is discussing the equivalence of
   |   expressions: equivalence of effect and value.

   I actually wonder about this.  I make a distinction between quote and
   backquote even in such cases.

   When I use quote, I am stating that I will not mutate the object, and that
   I may depend on its uniqueness -- i.e. no copying.

This is too much information to hang off of so unperspicuous a piece
of notation.  For example, as you surely know, mutating an object does
not perturb its uniqueness.  So there are at least two bits of information
being recorded in your single-bit choice of ` vs '.  And that's not even
accouting for using the backquote for its designed purpose.  While I heartily
endorse regular programming style, my point is really that if you want to
seriously make a design claim that these usages matter, we should consider
adding notations that make explicit what you want to have be implicit, since
these bits (uniqueness and modifiability) can usefully vary orthogonally,
and to bundle them up in a single package this way is strangling the 
expressive power of a very important set of issues.

   When I use backquote, I make no such statement.  In fact, I use it to
   create a list initialized with constants that I am willing to mutate.

   Thus I think of 

	   `(a b c)

   as equivalent to 

	   (list 'a 'b 'c)

Gack.  This completely thwarts efficient compilation of shared subtails
in complex backquote templates, forcing one to do exactly what one does
not want to do--create a template that does not look like the thing being
created in order to get efficiency. e.g.,

  `(lambda (,var x y z) (apply ,var x y z))

becomes

  `(lambda (,var ,@'(x y z)) (apply ,var ,@'(x y z)))

I find that completely unacceptable.  What you propose was introduced into
Maclisp for about a week (long enough for me to convert all my code to use
it, only to have that code all later broken by an incompatible change).  At
the end of that week, people decided constant subtails needed to be changed;
those of us who felt it incompatible with what we'd just done whined, but
the motivation (sharing) was ultimately well worth the cost.  So I'm sorry
if I don't buy this.

Backquote is one of those things like Emacs Control-T.  Its value is highly
fragile and it offers value only if installed "just so".  If you move Emacs
Control-T to a multi-character sequence, its value goes away.  Ditto for
backquote: if you make backquote so that to use it efficiently involves
complex idioms that destroy the visual shape of the code you're trying to 
match, you destroy the value of having had an operator that could be used 
to simply case-mark the "different places" by forcing the programmer to
case-mark "sharing places", too.  At that point, IMO, you've killed backquote.
Please just let it do what it wants to do--to be an efficient substitution
marker.  Don't get it involved in things it can't do--like declaring your
desire to mark mutability and uniqueness.

   while

	   '(a b c)

   is more like

	   ;; at top level

	   (define <hidden-variable> (list 'a 'b 'c))

	   ;; at use

	   <hidden-variable>

   I realize that the reports don't allow me to make that assumption, but
   I wonder whether backquote might not be more useful if they did.

   This distinction implies deep copying of back-quoted structure.  When
   actual insertion is desired, the following clumsy but clear idiom
   can be used

	   `(foo ,bar ,@'(joe mary frederick))

Yuck.