[plt-scheme] jumping comma

From: Anton van Straaten (anton at appsolutions.com)
Date: Sat Dec 31 11:08:02 EST 2005

Andreas Zwinkau wrote:
> I don't know, what to make out of this behaviour:
>    > '(jumping, comma)
>    (jumping ,comma)
> Why does the comma jump from "right of jumping" to "left of comma"?

The comma in Scheme is an abbreviation for UNQUOTE, used in conjunction 
with the QUASIQUOTE syntax.  So the expression '(jumping, comma) is 
actually shorthand for:

(quote (jumping (unquote comma)))

The UNQUOTE is associated with the argument to its right, so when it is 
printed as a comma, it is printed directly in front of its argument.

Section 6.3.2 of R5RS talks about this:

"Within literal expressions and representations of objects read by the 
READ procedure, the forms '<datum>, `<datum>, ,<datum>, and ,@<datum> 
denote two-element lists whose first elements are the symbols QUOTE, 
QUASIQUOTE, UNQUOTE, and UNQUOTE-SPLICING, respectively.  The second 
element in each case is <datum>.  This convention is supported so that 
arbitrary Scheme programs may be represented as lists.  That is, 
according to Scheme's grammar, every <expression> is also a <datum> (see 
section 7.1.2).  Among other things, this permits the use of the READ 
procedure to parse Scheme programs. See section 3.3."

Anton


Posted on the users mailing list.