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

Re: Binding the same variable twice in a single form

    Date: 17 Apr 90 16:23:31 GMT
    From: bbn.com!mesard@BBN.COM (Wayne Mesard)

    barmar@THINK.COM (Barry Margolin) writes:
    >Since the language doesn't specify what "the right thing" is, Symbolics
    >is completely justified in implementing inconsistent semantics.

    Not according to CLtL p.2.  "[T]he interpreter and compiler [are
    required] to impose identical semantics on correct programs so far as

But the program under discussion is not a "correct program", so the
implementation-dependent behavior is not required to be consistent
between the compiler and interpreter.  The results of incorrect programs
are not specified by CLtL; in fact, it would be valid for

(let ((a 1)
      (a 2))

to return 3.  In fact, I can imagine an implementation for a PDP-8-like
machine that would do so.  The PDP-8 has no LOAD instruction, only an
instruction that adds from memory into a register (the PDP-8 only has
one accumulator, but I'm postulating a system with multiple registers
but instructions similar to the PDP-8).  The code for a LET would clear
all the registers to be used for the variables being bound, compute the
values, and then assign to the registers using the addition instruction.
In this case, it would assign to the A register twice, thus adding the
values together.