[plt-scheme] Semantics of quote

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Jun 24 01:34:34 EDT 2008

On Tue, Jun 24, 2008 at 12:28 AM, Eli Barzilay <eli at barzilay.org> wrote:
> On Jun 24, Robby Findler wrote:
>>
>> None of those seem like good ideas. I can see why you don't like that!
>> I wouldn't suggest that. FWIW, you can actually try this stuff out.
>> There's the constructor-style printing in drscheme where you get:
>
> I know about it, of course, and it's a bad idea for general
> hacking.
>
>  (define (a) 1)
>  (define (b) 2)
>  (list a b)

Obviously, this prints as

  (list a b)

or

  `(,a ,b)

which seems just as good as

  '(#<procedure:a> #<procedure:b>)

But I'd be fine with a different way to print (unquoted) procedures.
Something like we do in the teaching languages perhaps:

  (list function:a function:b)

or a variation on that.

>> > IMO, if you add quote, you should go for the first option or
>> > better not use pretty printing.  The contradicting goals are quote
>> > trying to make results look like values and pretty-printing makes
>> > them look like code.
>>
>> "add quote" is the wrong way to put it, I believe. "Avoid removing
>> quote" is the right way to say it, IMO. But that's just terminology.
>
> I can say the opposite and have a perfectly valid view of the world...

Right. Except that the quote is really there.

>> The contradiction is still manifest in what I'm suggesting, but it
>> shows up in the choice of "quasiquote" printing vs "constructor
>> style" printing. All I'm trying to fix is to make the output use
>> input notation (I really just want input and output notation to
>> match up and I suppose one coudl try to make input use the current
>> output notation but that seems like the wrong choice.)
>
> But that doesn't work for cases like functions and other unpritable
> values.

As I wrote, it continues to not work in the same ways, except you
don't have to make up new notations in a few cases (ie, primitive
names are the same).

> what I'm talking about is the fact
> that with constructor style (and quasiquote style, for things that are
> not lists), printout size is exponential to the level of quotedness,
> because each construtor needs to be quoted itself.

This seems to be wrong. Here's what I tried. I guess you still haven't
taken me up on my invitation to try this out in drscheme.

;; in constructor mode:
> ''''(λ (x) x)
(list 'quote (list 'quote (list 'quote (list 'λ (list 'x) 'x))))
;; in qq mode:
> ''''(λ (x) x)
`'''(λ (x) x)

Robby

Posted on the users mailing list.