[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what about dropping rest-lists?



Sebastian Egner <sebastian.egner@xxxxxxxxxxx> 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/