[plt-scheme] Re: Trouble using map with object methods

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Sun Jul 10 02:11:43 EDT 2005

On Sun, 10 Jul 2005, Marc Fernandez Vilaseca wrote:

> Interestingly, though, "Teach Yourself Scheme in Fixnum Days" seems to
> suggest that using quote to create a list is acceptable syntaxis:
>
> > list takes any number of arguments and returns the list containing them:
> >
> > (list 1 2 3 4)
> > =>  (1 2 3 4)
> >
> > Indeed, if we know all the elements of a list, we can use quote to
> > specify the list:
>
> > '(1 2 3 4)
> > =>  (1 2 3 4)


Hi Mark,

The quote form that you're using is a shortened form of the "quote"
special form:

     'foo        <====>     (quote foo)


QUOTE works by not evaluating the thing that follows it, but returning the
quoted value literally.  For example:

;;;;;;
> (list + - * /)
(#<primitive:+> #<primitive:-> #<primitive:*> #<primitive:/>)
;;;;;;


results in a list of four function values, but:

;;;;;;
> (quote (+ - * /))
(+ - * /)
;;;;;;

returns a literal list of those four symbols.  They're different, as we
can see from the display.

So using quote for lists is acceptable if we don't mind that the quoted
thing isn't being evaluated.  But in your example, you do want evaluation,
so quotation is probably not what you want.

Best of wishes to you!



Posted on the users mailing list.