From: netytan
Subject: Why ` and '
Date: 
Message-ID: <1138478244.376746.251820@o13g2000cwo.googlegroups.com>
Just curious I guess but why do all modern Lisps include a quote and
quasiquote syntax, would it not be better from a syntatic point of view
to simply have the latter of the two; It would IMO look much cleaner
:). So what are the reasons for having both and are they good reasons?

Thanks all,

Mark.

From: Coby Beck
Subject: Re: Why ` and '
Date: 
Message-ID: <GKQCf.154253$km.24845@edtnps89>
"netytan" <·······@gmail.com> wrote in message 
·····························@o13g2000cwo.googlegroups.com...
> Just curious I guess but why do all modern Lisps include a quote and
> quasiquote syntax, would it not be better from a syntatic point of view
> to simply have the latter of the two; It would IMO look much cleaner
> :). So what are the reasons for having both and are they good reasons?

That's good point, I never really thought of that before.  Another poster 
provided a very likely practical reason, "just because" (ok, he called it 
historical ;) but I think it is worth it to have both.  ' is ' and it tells 
the reader (human reader that is) something.  Seeing a backquote is a very 
different visual clue about what is about to happen.

-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Harald Hanche-Olsen
Subject: Re: Why ` and '
Date: 
Message-ID: <pcowtgkxf2b.fsf@shuttle.math.ntnu.no>
+ "netytan" <·······@gmail.com>:

| Just curious I guess but why do all modern Lisps include a quote and
| quasiquote syntax, would it not be better from a syntatic point of view
| to simply have the latter of the two; It would IMO look much cleaner
| :). So what are the reasons for having both and are they good reasons?

I can't say for sure about this particular one, but you will find that
a lot things are the way they are in Lisp for historical reasons.
Making changes in the language that break backward compaitibility is
very costly, and is therefore avoided unless the benefits outweigh the
costs.  And given that quote has been around much longer than
quasiquote, I guess you can see why nobody is eager to throw it out.

-- 
- It is undesirable to believe a proposition when there is no ground whatsoever
  for supposing it is true.  -- Bertrand Russell
From: Pascal Costanza
Subject: Re: Why ` and '
Date: 
Message-ID: <4423afFkk7U1@individual.net>
netytan wrote:
> Just curious I guess but why do all modern Lisps include a quote and
> quasiquote syntax, would it not be better from a syntatic point of view
> to simply have the latter of the two; It would IMO look much cleaner
> :). So what are the reasons for having both and are they good reasons?

There are cases where you need to be able to express `',var and similar 
idioms. This isn't possible if there is only `


Pascal

-- 
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
From: Kaz Kylheku
Subject: Re: Why ` and '
Date: 
Message-ID: <1138730930.423952.206360@g43g2000cwa.googlegroups.com>
Pascal Costanza wrote:
> netytan wrote:
> > Just curious I guess but why do all modern Lisps include a quote and
> > quasiquote syntax, would it not be better from a syntatic point of view
> > to simply have the latter of the two; It would IMO look much cleaner
> > :). So what are the reasons for having both and are they good reasons?
>
> There are cases where you need to be able to express `',var and similar
> idioms. This isn't possible if there is only `

Oh yes, good point.

  (defvar a 3)

  (eval (let ((a 42)) ``,a)) --> 3

  (eval (let ((a 42)) `',a)) --> 42

The leftmost comma belongs to the innermost backquote. So when the
inner backquote is introduced it ``steals'' the unquote.  The regular
quote gives us a quote operator that we can use within a backquote,
that doesn't steal unquotes references.
From: Frank Buss
Subject: Re: Why ` and '
Date: 
Message-ID: <nzcdonnx7yg1.uha0tagv03q9$.dlg@40tude.net>
netytan wrote:

> Just curious I guess but why do all modern Lisps include a quote and
> quasiquote syntax, would it not be better from a syntatic point of view
> to simply have the latter of the two; It would IMO look much cleaner
> :). So what are the reasons for having both and are they good reasons?

See this posting from Guy Steele:

http://groups.google.de/group/comp.lang.scheme/msg/672366d701c2cae4

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: netytan
Subject: Re: Why ` and '
Date: 
Message-ID: <1138487110.471637.280380@g49g2000cwa.googlegroups.com>
Thats a very good reason, not one I'd considered. Probably because I
generally use Scheme more than CL and so don't have to contend with `
for the most part - it seems to be much more common in CL :).

The may i alter my question, why was quasi-quote added to the language.
It doesn't seem as though it offers much when compared to quote for the
most part, surely it doesn't provide a way of doing things you couldn't
do using quote only?

Thanks for all you're responses guys, they're very helpful and much
appreciated.

Mark.
From: Tayssir John Gabbour
Subject: Re: Why ` and '
Date: 
Message-ID: <1138489370.961465.311550@o13g2000cwo.googlegroups.com>
netytan wrote:
> Thats a very good reason, not one I'd considered. Probably because I
> generally use Scheme more than CL and so don't have to contend with `
> for the most part - it seems to be much more common in CL :).
>
> The may i alter my question, why was quasi-quote added to the language.
> It doesn't seem as though it offers much when compared to quote for the
> most part, surely it doesn't provide a way of doing things you couldn't
> do using quote only?
>
> Thanks for all you're responses guys, they're very helpful and much
> appreciated.
>
> Mark.

In "The Evolution of Lisp" (p. 74 and 75), the issue is framed in terms
of expressive power. Then in the next couple of pages, they discuss the
Scheme community's attempts for further improvevements.
http://www.dreamsongs.com/NewFiles/HOPL2-Uncut.pdf&e=10401

As usual, the claims are not about power in the Turing completeness
sense, but rather what is more expressive.

For example, one could claim that normal quote isn't needed because:
`',x is semantically identical to `(quote ,x)

But hey, it's not like there's a pressing need for backquote to do
other duty. ;)


Tayssir
From: Tayssir John Gabbour
Subject: Re: Why ` and '
Date: 
Message-ID: <1138489540.867365.103370@g49g2000cwa.googlegroups.com>
Tayssir John Gabbour wrote:
> netytan wrote:
> > Thats a very good reason, not one I'd considered. Probably because I
> > generally use Scheme more than CL and so don't have to contend with `
> > for the most part - it seems to be much more common in CL :).
> >
> > The may i alter my question, why was quasi-quote added to the language.
> > It doesn't seem as though it offers much when compared to quote for the
> > most part, surely it doesn't provide a way of doing things you couldn't
> > do using quote only?
> >
> > Thanks for all you're responses guys, they're very helpful and much
> > appreciated.
> >
> > Mark.
>
> In "The Evolution of Lisp" (p. 74 and 75), the issue is framed in terms
> of expressive power. Then in the next couple of pages, they discuss the
> Scheme community's attempts for further improvevements.
> http://www.dreamsongs.com/NewFiles/HOPL2-Uncut.pdf&e=10401

Hmm, Google mangling. Here's the right link:
http://www.dreamsongs.com/NewFiles/HOPL2-Uncut.pdf
From: Bill Atkins
Subject: Re: Why ` and '
Date: 
Message-ID: <87hd7ovuyl.fsf@rpi.edu>
"netytan" <·······@gmail.com> writes:

> Thats a very good reason, not one I'd considered. Probably because I
> generally use Scheme more than CL and so don't have to contend with `
> for the most part - it seems to be much more common in CL :).
>
> The may i alter my question, why was quasi-quote added to the language.
> It doesn't seem as though it offers much when compared to quote for the
> most part, surely it doesn't provide a way of doing things you couldn't
> do using quote only?
>
> Thanks for all you're responses guys, they're very helpful and much
> appreciated.
>
> Mark.

Backquote makes macro writing much, much easier by allowing you to
selectively unquote parts of a list.  For instance, compare

  (defmacro when (clause &body body)
     (append (list 'if clause) body))

to

  (defmacro when (clause &body body)
     `(if ,clause
          ,@body
          nil))

Both are equivalent, but with backquote, it's immediately apparent
that WHEN is closely related to IF - we can see the structure of the
generated code and see where the arguments are evaluated.  Without the
backquote facility, generating code using the first method would
become extremely awkward and difficult to maintain if the macro's
expansion is complicated at all.

For more information, see < http://gigamonkeys.com/book/macros-defining-your-own.html > .

HTH,
Bill
From: Bill Atkins
Subject: Re: Why ` and '
Date: 
Message-ID: <87acdgvus8.fsf@rpi.edu>
Bill Atkins <············@rpi.edu> writes:

> "netytan" <·······@gmail.com> writes:
>
>> Thats a very good reason, not one I'd considered. Probably because I
>> generally use Scheme more than CL and so don't have to contend with `
>> for the most part - it seems to be much more common in CL :).
>>
>> The may i alter my question, why was quasi-quote added to the language.
>> It doesn't seem as though it offers much when compared to quote for the
>> most part, surely it doesn't provide a way of doing things you couldn't
>> do using quote only?
>>
>> Thanks for all you're responses guys, they're very helpful and much
>> appreciated.
>>
>> Mark.
>
> Backquote makes macro writing much, much easier by allowing you to
> selectively unquote parts of a list.  For instance, compare
>
>   (defmacro when (clause &body body)
>      (append (list 'if clause) body))
>
> to
>
>   (defmacro when (clause &body body)
>      `(if ,clause
>           ,@body
>           nil))
>
> Both are equivalent, but with backquote, it's immediately apparent
> that WHEN is closely related to IF - we can see the structure of the
> generated code and see where the arguments are evaluated.  Without the
> backquote facility, generating code using the first method would
> become extremely awkward and difficult to maintain if the macro's
> expansion is complicated at all.
>
> For more information, see < http://gigamonkeys.com/book/macros-defining-your-own.html > .
>
> HTH,
> Bill

Oops.  Both of my code examples are broken.  Here are correct ones:

  (defmacro when (clause &body body)
     (list 'if clause 
       (cons 'progn body)
       nil))

and

  (defmacro when (clause &body body)
     `(if ,clause
          (progn
             ,@body)
          nil))

Sorry.
From: Pascal Bourguignon
Subject: Re: Why ` and '
Date: 
Message-ID: <87hd7ormmy.fsf@thalassa.informatimago.com>
"netytan" <·······@gmail.com> writes:
> The may i alter my question, why was quasi-quote added to the language.
> It doesn't seem as though it offers much when compared to quote for the
> most part, surely it doesn't provide a way of doing things you couldn't
> do using quote only?

`(here is an ,(list example of why) backquote ,@(was added to the) langage)

(append (list (quote here) (quote is) (quote an) (list example of why)
              (quote backquote))
        (append (was added to the) (list (quote language))))


Even  if you use ':

(append (list 'here 'is 'an (list example of why) 'backquote)
        (append (was added to the) (list 'language)))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You're always typing.
Well, let's see you ignore my
sitting on your hands.
From: Pascal Costanza
Subject: Re: Why ` and '
Date: 
Message-ID: <442givF2lgcU1@individual.net>
netytan wrote:
> Thats a very good reason, not one I'd considered. Probably because I
> generally use Scheme more than CL and so don't have to contend with `
> for the most part - it seems to be much more common in CL :).
> 
> The may i alter my question, why was quasi-quote added to the language.
> It doesn't seem as though it offers much when compared to quote for the
> most part, surely it doesn't provide a way of doing things you couldn't
> do using quote only?

I think you cannot get a more extensive rationale than the one given in 
http://citeseer.ist.psu.edu/bawden99quasiquotation.html


Pascal

-- 
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
From: Kaz Kylheku
Subject: Re: Why ` and '
Date: 
Message-ID: <1138731990.710517.18470@z14g2000cwz.googlegroups.com>
netytan wrote:
> Thats a very good reason, not one I'd considered. Probably because I
> generally use Scheme more than CL and so don't have to contend with `
> for the most part - it seems to be much more common in CL :).
>
> The may i alter my question, why was quasi-quote added to the language.
> It doesn't seem as though it offers much when compared to quote for the
> most part, surely it doesn't provide a way of doing things you couldn't
> do using quote only?

Quote doesn't interpolate values into a template. So that is a thing
you can't do with just  quote, and it's quite a big thing.

Have you ever looked at the code produced by backquotes?

You'd have to write that by hand and later try to understand it.

Exercise: write the code which constructs the equivalent of

 `(((a b ,c)))

The C is buried in two levels of list nesting. So you have to do:

 (list (list (list 'a 'b c)))

A simple example, and it's already getting pretty ugly. Now try double
backquote:

  ``(((a ,',b ,,c) ,',d))

This is where I get completely lazy. It's so hard to do that I cheat by
going into CLISP and doing

  (macroexpand '``(((a ,',b ,,c) ,',d)))

  --> (LIST 'LIST (LIST 'LIST (LIST 'LIST ''A (LIST 'QUOTE B) C) (LIST
'QUOTE D)))

CLISP has a nice macro-based backquote that produces pretty code based
on standard CL operators.  This makes it a good backquote learning aid
for newbies.

Anyway, you can see how it's getting confusing with two levels of
backquote. You have LIST appearing as a regular function, and also the
symbol 'LIST being quoted. The backquote produces code which produces
code, which produces a list.

The nested backquote is hard to understand too, but less so.
From: Kaz Kylheku
Subject: Re: Why ` and '
Date: 
Message-ID: <1138730269.930168.164030@g49g2000cwa.googlegroups.com>
netytan wrote:
> Just curious I guess but why do all modern Lisps include a quote and
> quasiquote syntax, would it not be better from a syntatic point of view
> to simply have the latter of the two; It would IMO look much cleaner
> :). So what are the reasons for having both and are they good reasons?

This is a lot like the discussion about why SETQ is needed if there is
SETF. The SETQ interface isn't necessary, but SETF internally needs
something that works like SETQ: an operator that can assign to a
variable.

Similarly, backquote needs something to fall back on in order to
produce simple literals. If the QUOTE public interface didn't exist,
there would still have to be some internal operator which does the same
thing. This would allow for instance `(a b c) to generate something
like (SYSTEM::QUOTE (A B C)) where SYSTEM represents an
implementation's private package.

I.e there has to be some target syntax that can specify a simple
literal that does not have to be scanned for unquoted material.

Reasonable implementations of backquote produce the regular quote
whenever possible either for the whole thing or at least for some of
the constituent parts. e.g something like

  `(,a ,b (c d) e ,f (g h))

should expand to something along the lines of

  (list a b '(c d) 'e f '(g h))

There are no more backquotes left and so the expansion is done.

If a backquote were used for '(c d) and '(g h), then the backquote
expansion function would never terminate.
From: Rob Thorpe
Subject: Re: Why ` and '
Date: 
Message-ID: <1138731045.046501.282640@z14g2000cwz.googlegroups.com>
netytan wrote:
> Just curious I guess but why do all modern Lisps include a quote and
> quasiquote syntax, would it not be better from a syntatic point of view
> to simply have the latter of the two; It would IMO look much cleaner
> :). So what are the reasons for having both and are they good reasons?

Something no-one else has mentioned.

You can implement a lisp by implementing ' in the underlying language.
After you've done that you can have ` dealt with by the reader and
implemented in lisp AFAIK.