Jonathan S. Shapiro wrote: > On Thu, Mar 5, 2009 at 10:30 AM, Geoffrey Irving <[email protected]> wrote: >> On Thu, Mar 5, 2009 at 6:17 AM, Jonathan S. Shapiro <[email protected]> wrote: >>> Let me start over. The issue is that the following input to ocaml >>> produces 3 when it should produce an unbound reference error (x should >>> be unbound in "x + 2"). >>> >>> # let x = 1 in x; let y = x + 2 in y;; >>> - : int = 3 >>> >>> The problem is that the *following* expression is equivalent and >>> *terribly* confusing: >>> >>> # let x = 1 in begin x end; let y = x + 2 in y;; >>> - : int = 3 >>> >>> The desired behavior can apparently be obtained only with begin/end or >>> parenthesis: >>> >>> # (let x = 1 in x); let y = x + 2 in y;; >>> Unbound value x >> How is this different from C? > > The difference is seen in the second case: > > # let x = 1 in begin x end; let y = x + 2 in y;; > > In EVERY other language I can think of, that begin/end pair would > define the scope of the let, [...]
Why? The begin..end delimits only the use of x, not the let. > and because of that history, it is guaranteed to be read that way > by humans. I didn't read it that way. I agree that 'let' should be explicitly delimited, but I don't think this example shows the point. -- David-Sarah Hopwood ⚥ _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
