Why quasiquote without macros? 
Author Message
 Why quasiquote without macros?

So, why does R^4RS _require_ quasiquote, but not even define
macros?  When would you use quasi in a non-macro environment?

- David



Tue, 15 Oct 1996 07:05:56 GMT  
 Why quasiquote without macros?

Quote:
> So, why does R^4RS _require_ quasiquote, but not even define
> macros?  When would you use quasi in a non-macro environment?

; Here's one case
      (define immutable-list '(red green))  ; see sec. 3.5 of standard
      (define initialized-mutable-list `(red green))

; Here's another
      (define complicated-list `((yes (oui ja))
                                 ,(compute-some-stuff-here)
                                 (no (non nein))
                                 ,(compute-some-more-stuff-here)
                                 (unknown (inconnu unbekannt))))

You can achieve the same effects in other ways, e.g. by using (list...)
and quot(')ing the appropriate parts, but the quasiquote (`) gives what
I, at least, find a pleasant terseness.
--

SoftQuad Inc., Toronto  |  you haven't thought of."        -- David Slocombe

This article is in the public domain.



Tue, 15 Oct 1996 22:23:17 GMT  
 Why quasiquote without macros?
Subject: Why quasiquote without macros?

Date: Thu, 28 Apr 1994 23:05:56 GMT


Quote:
>So, why does R^4RS _require_ quasiquote,
> but not even define macros?  When would
> you use quasi in a non-macro environment?

I don't see how quasiquote and macros are related
(at the interface level).

Use of quasiquote -- no macros:
  (define (frobize verb)
    `(the frobish ,verb was flammish))

  (frobize 'move) ;--> (the frobish move was flammish)

Macro definition without quasiquote:
  (define-syntax UNLESS
     (syntax-rules ()
        ((unless <condition> <body> ...)
         ;; =>
         (if <condition> #f (begin <body> ...)))
   )  )

Cheers,
-Ken



Wed, 16 Oct 1996 01:37:12 GMT  
 Why quasiquote without macros?

Quote:

>       (define immutable-list '(red green))  ; see sec. 3.5 of standard
>       (define initialized-mutable-list `(red green))

but as Lars Thomas Hansen was the first to point out in email, I was wrong
to assume that `(red green) must return a mutable list.  It just happens
that the Scheme implementation *I* use allows me to mutate it...

The R4RS says in section 3.5 that

#  The constants and the strings returned by symbol->string are ... the
#  immutable objects, while all objects created by the other procedures
#  listed in this report are mutable.

and in section 4.1.2, essentially, that '(red green) is a constant that
therefore immutable.  Now section 4.2.6 says:

#  If no commas appear within the <template>, the result of evaluating
#  `<template> is equivalent to the result of evaluating '<template>.

If quasiquote was a procedure, it would have to return a mutable list, but
it's syntax, and the above wording makes its result immutable.  (That is,
the implementation is allowed to enforce its immutability).

However, at least, my second example of quasiquote's utility stands.
--

SoftQuad Inc., Toronto                                   -- Tom Van Vleck

This article is in the public domain.



Wed, 16 Oct 1996 04:52:22 GMT  
 Why quasiquote without macros?


   > So, why does R^4RS _require_ quasiquote, but not even define
   > macros?  When would you use quasi in a non-macro environment?

   ; Here's one case
         (define immutable-list '(red green))  ; see sec. 3.5 of standard
         (define initialized-mutable-list `(red green))

In my copy of R4RS (p.11, section 4.2.6. ``Quasiquotation'') is says:
``... If no commas appear within the <template>, the result of
evaluating `<template> is equivalent to the result of evaluating
'<template>. ...''.

As far as I'm concerned this means that `(red green) is as immutable
as '(red green).  In fact, I would argue that the whole result of
`<template> minus the parts explicitely evaluated must be considered
constants.


'a (append b '(c d))).  Therefore, the (c d) part of the result must
be considered immutable.  In general it is not clear how the
compiler's translation of a quasiquote expression will look like,
hence extreme caution is advisable.

--
-Matthias



Wed, 16 Oct 1996 01:22:29 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Quasiquote implementation using macros?

2. Macros and quasiquote?

3. Turning a list value in a parameter into a list for eval without quasiquote/unquote

4. why is quasiquote necessary?

5. why why why oh why why baby

6. proc without stack frame OR macro instead of proc

7. A macro involving two sub-macros - where the 2nd macro needs results from the first

8. why not SQRT in the Macro Processor?

9. Why macros impair readability

10. Why macros impair readability (long)

11. why do they call it macro assembler ?

12. Why no macro facility?

 

 
Powered by phpBB® Forum Software