From: Pedro Kroger
Subject: what the period-comma reader macro does?
Date: 
Message-ID: <3f4ad5c6-e3b5-409a-8ab9-5b6cd2e49450@v39g2000pro.googlegroups.com>
Hi,

I'm studying the scheme implementation in PAIP [1] and I saw a period-
comma reader macro (.,) in the following code:

(def-scheme-macro let (bindings &rest body)
  `((lambda ,(mapcar #'first bindings) . ,body)
    .,(mapcar #'second bindings)))

What it does? is it part of ANSI? I tried to find it in CLHS but I
couldn't. (I found about comma-period, but not period-comma). It seems
to me it just expand into comma-at, but why is it used at all?

(macroexpand-1 '(`(foo .,bar))) => (`(FOO ,@BAR))

Pedro

[1] http://norvig.com/paip/interp1.lisp

From: ······@gmail.com
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <f05b325a-be4e-4984-877a-5572b682c0f8@40g2000prx.googlegroups.com>
On Nov 14, 7:17 am, Pedro Kroger <············@gmail.com> wrote:
> Hi,
>
> I'm studying the scheme implementation in PAIP [1] and I saw a period-
> comma reader macro (.,) in the following code:
>
> (def-scheme-macro let (bindings &rest body)
>   `((lambda ,(mapcar #'first bindings) . ,body)
>     .,(mapcar #'second bindings)))
>
> What it does? is it part of ANSI? I tried to find it in CLHS but I
> couldn't. (I found about comma-period, but not period-comma). It seems
> to me it just expand into comma-at, but why is it used at all?
>
> (macroexpand-1 '(`(foo .,bar))) => (`(FOO ,@BAR))
>
> Pedro
>
> [1]http://norvig.com/paip/interp1.lisp


Note that these syntax irregularities is a frequent source of
confusion.

For detail, see:

• Fundamental Problems of Lisp
http://xahlee.org/UnixResource_dir/writ/lisp_problems.html

here's a plain text excerpt of the intro:
--------------------------------------
Fundamental Problems of Lisp

Xah Lee, 2008-07

In this article, i discuss 2 problems that are rooted in lisp. One is
the irregularity in its often cited regular syntax. The other is the
language's use of “cons” for list.

Syntax Irregularities

Lisp family of languages, in particular, Common Lisp, Scheme Lisp,
Emacs Lisp, are well know for its syntax's regularity, namely,
“everything” is of the form “(f x1 x2 ...)”. However, it is little
talked about that there are several irregularities in its syntax. Here
are some examples of the syntax irregularity.

    * The comment syntax of semicolon to end of line “;”.
    * The dotted notation for cons cell “(1 . 2)”.
    * The single quote syntax used to hold evaluation, e.g. “'(1 2
3)”.
    * The backquote and comma syntax used to hold but evaluate parts
of expression, e.g. “(setq x 1) (setq myVariableAndValuePair `
(x ,x))”.
    * The “,@” for inserting a list as elements into another list.
e.g. “(setq myListX (list 1 2)) (setq myListY (list 3 4)) (setq
myListXY `(,@ myListX ,@ myListY))”
    * There are various others in Common Lisp or Scheme Lisp. For
example, the char “#” and “#|”. In Scheme's R6RS, it has introduced a
few new ones.

In the following, i detail how these irregularities hamper the power
of regular syntax, and some powerful features and language
developments that lisp have missed that may be due to it.

  Xah
∑ http://xahlee.org/

☄
From: leppie
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <636f8292-3f3f-434b-9fb0-c3a6dba7abbf@b38g2000prf.googlegroups.com>
On Nov 14, 7:58 pm, ·······@gmail.com" <······@gmail.com> wrote:
> On Nov 14, 7:17 am, Pedro Kroger <············@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I'm studying the scheme implementation in PAIP [1] and I saw a period-
> > comma reader macro (.,) in the following code:
>
> > (def-scheme-macro let (bindings &rest body)
> >   `((lambda ,(mapcar #'first bindings) . ,body)
> >     .,(mapcar #'second bindings)))
>
> > What it does? is it part of ANSI? I tried to find it in CLHS but I
> > couldn't. (I found about comma-period, but not period-comma). It seems
> > to me it just expand into comma-at, but why is it used at all?
>
> > (macroexpand-1 '(`(foo .,bar))) => (`(FOO ,@BAR))
>
> > Pedro
>
> > [1]http://norvig.com/paip/interp1.lisp
>
> Note that these syntax irregularities is a frequent source of
> confusion.
>
> For detail, see:
>
> • Fundamental Problems of Lisphttp://xahlee.org/UnixResource_dir/writ/lisp_problems.html
>
> here's a plain text excerpt of the intro:
> --------------------------------------
> Fundamental Problems of Lisp
>
> Xah Lee, 2008-07
>
> In this article, i discuss 2 problems that are rooted in lisp. One is
> the irregularity in its often cited regular syntax. The other is the
> language's use of “cons” for list.
>
> Syntax Irregularities
>
> Lisp family of languages, in particular, Common Lisp, Scheme Lisp,
> Emacs Lisp, are well know for its syntax's regularity, namely,
> “everything” is of the form “(f x1 x2 ...)”. However, it is little
> talked about that there are several irregularities in its syntax. Here
> are some examples of the syntax irregularity.
>
>     * The comment syntax of semicolon to end of line “;”.
>     * The dotted notation for cons cell “(1 . 2)”.
>     * The single quote syntax used to hold evaluation, e.g. “'(1 2
> 3)”.
>     * The backquote and comma syntax used to hold but evaluate parts
> of expression, e.g. “(setq x 1) (setq myVariableAndValuePair `
> (x ,x))”.
>     * The “,@” for inserting a list as elements into another list.
> e.g. “(setq myListX (list 1 2)) (setq myListY (list 3 4)) (setq
> myListXY `(,@ myListX ,@ myListY))”
>     * There are various others in Common Lisp or Scheme Lisp. For
> example, the char “#” and “#|”. In Scheme's R6RS, it has introduced a
> few new ones.
>
> In the following, i detail how these irregularities hamper the power
> of regular syntax, and some powerful features and language
> developments that lisp have missed that may be due to it.
>
>   Xah
> ∑http://xahlee.org/
>
> ☄

., is not valid in Scheme. The comma is not a valid delimiter for a
dot.

Cheers

leppie
From: Tobias C. Rittweiler
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <8763mqgwce.fsf@freebits.de>
Pedro Kroger <············@gmail.com> writes:

> Hi,
>
> I'm studying the scheme implementation in PAIP [1] and I saw a period-
> comma reader macro (.,) in the following code:
>
> (def-scheme-macro let (bindings &rest body)
>   `((lambda ,(mapcar #'first bindings) . ,body)
>     .,(mapcar #'second bindings)))
>
> What it does? is it part of ANSI? I tried to find it in CLHS but I
> couldn't. (I found about comma-period, but not period-comma). It seems
> to me it just expand into comma-at, but why is it used at all?

It's the consing dot followed by an unquoting comma. There's no
particular reason to prefer it to ,@.

  -T.
From: Scott Burson
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <40125d07-805a-4ece-99d4-36ac55db59fb@f40g2000pri.googlegroups.com>
On Nov 14, 7:29 am, "Tobias C. Rittweiler" <····@freebits.de.invalid>
wrote:
> It's the consing dot followed by an unquoting comma. There's no
> particular reason to prefer it to ,@.

I use it to indicate appending, as in Pedro's example.  That way, ,@
always indicates actual splicing -- the list being spliced in is not
the last thing in the list being constructed.

But it's not a very important distinction.

-- Scott
From: Pedro Kroger
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <74d70d79-d3cf-4a9b-8090-28cec8f0b0f1@r37g2000prr.googlegroups.com>
On Nov 14, 12:29 pm, "Tobias C. Rittweiler" <····@freebits.de.invalid>
wrote:

> It's the consing dot followed by an unquoting comma. There's no
> particular reason to prefer it to ,@.

oh, now I see it. thanks.

pedro
From: Kaz Kylheku
Subject: Re: what the period-comma reader macro does?
Date: 
Message-ID: <20081114093734.483@gmail.com>
On 2008-11-14, Tobias C. Rittweiler <···@freebits.de.invalid> wrote:
> Pedro Kroger <············@gmail.com> writes:
>
>> Hi,
>>
>> I'm studying the scheme implementation in PAIP [1] and I saw a period-
>> comma reader macro (.,) in the following code:
>>
>> (def-scheme-macro let (bindings &rest body)
>>   `((lambda ,(mapcar #'first bindings) . ,body)
>>     .,(mapcar #'second bindings)))
>>
>> What it does? is it part of ANSI? I tried to find it in CLHS but I
>> couldn't. (I found about comma-period, but not period-comma). It seems
>> to me it just expand into comma-at, but why is it used at all?
>
> It's the consing dot followed by an unquoting comma. There's no
> particular reason to prefer it to ,@.

Likewise, there is no particular reason to write it as .,FORM 
rather than . ,FORM