Email list hosting service & mailing list manager

(Previous discussion continued)
Re: what about dropping rest-lists? Neil W. Van Dyke (18 May 2005 14:00 UTC)

Re: what about dropping rest-lists? Neil W. Van Dyke 18 May 2005 14:00 UTC

Sebastian Egner <xxxxxx@philips.com> wrote at 2005-05-18T11:15:21+0200:
> I still like Neil's (rest x) idea for it's readability, but it does
> not cover the empty case.

Does the following work?

    (let ( (a b c          (values 1 2 3)) ) c)   ;=> 3
    (let ( (a b            (values 1 2  )) ) b)   ;=> 2
    (let ( (a              (values 1    )) ) a)   ;=> 1
    (let ( (               (values      )) ) #f)  ;; no values

    (let ( (a b c (rest x) (values 1 2 3)) ) x)   ;=> ()
    (let ( (a b   (rest x) (values 1 2 3)) ) x)   ;=> (3)
    (let ( (a     (rest x) (values 1 2 3)) ) x)   ;=> (2 3)
    (let ( (      (rest x) (values 1 2 3)) ) x)   ;=> (1 2 3)

    (let ( (      (rest x) (values 1 2 3)) ) x)   ;=> (1 2 3)
    (let ( (      (rest x) (values 1 2  )) ) x)   ;=> (1 2)
    (let ( (      (rest x) (values 1    )) ) x)   ;=> (1)
    (let ( (      (rest x) (values      )) ) x)   ;=> ()

The change to the R5RS BNF "binding spec" production(s):

    <binding spec> --> (<variable>*                   <expression>)
                    |  (<variable>* (rest <variable>) <expression>)

By the way, I neglected to observe yesterday that the parens around the
"rest" clause are *necessary* for machine disambiguation, since we want
to permit "rest" as a variable identifier in all cases.

--
                                             http://www.neilvandyke.org/