Re: "let*" bug?

From: Erik Ostrom <eostrom_at_ccs.neu.edu>
Date: Thu, 15 Jun 1995 20:24:40 -0400

> >From the R4RS (I'm looking at the texinfo version created by Aubrey
> Jaffer; I recommend it highly):
>
> - essential syntax: let <bindings> <body>
> *Syntax:* <Bindings> should have the form
> ((<variable 1> <init 1>) ...),
> where each <init> is an expression, and <body> should be a
> sequence of one or more expressions. It is an error for a
> <variable> to appear more than once in the list of variables being
> bound.
>
> Note that last sentence. Later on "let*" is said to be "similar to
> `let'".

Yes, but apparently not similar in this way. The expansion given in
the formal semantics for let* (not available in the info version,
sadly) makes it possible to use the same variable twice, and a few
people (including one of the R4RS editors) have expressed surprise
on comp.lang.scheme that the document could be read any other way.

I'd kind of prefer that the same variable _not_ be able to be used twice
in a let*, but the de facto standard and (somewhat arguably) the formal
standard allow it.

If anyone cares, the patch to bring STk into line with other Schemes here
is a trivial change to syntax_let_family() in Src/syntax.c:

*** syntax.c.orig Thu Jun 15 20:09:40 1995
--- syntax.c Thu Jun 15 20:07:51 1995
***************
*** 212,218 ****
        Err(buffer, CONSP(p)? tmp: p);
      }
      /* Verify that this binding doesn't already exist in fl */
! if (STk_memv(CAR(tmp),fl)!=Ntruth) {
        sprintf(buffer, "%s: duplicate binding", who);
        Err(buffer, CAR(CDR(*pform)));
      }
--- 212,218 ----
        Err(buffer, CONSP(p)? tmp: p);
      }
      /* Verify that this binding doesn't already exist in fl */
! if ((type != tc_letstar) && (STk_memv(CAR(tmp),fl)!=Ntruth)) {
        sprintf(buffer, "%s: duplicate binding", who);
        Err(buffer, CAR(CDR(*pform)));
      }
Received on Fri Jun 16 1995 - 02:26:17 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST