I've used OCaml a lot, but I actually prefer Haskell's let binding.
In Haskell, I can write:
let { x = 1; y = 2 } in x + y
let x = 1; y = 2 in x + y
let x = 1
y = 1
in
x + y
and also
x + y where x = 1; y = 2
This is related to the indentation rules, but it works out quite nicely.
The following:
let x = 1
y = 2
in
x + y
Is translated to something like:
let { x = 1;
y = 2
} in x + y
As a matter of fact, the core Haskell syntax for let is:
exp: "let" decls "in" exp
| ...
decls: "{" (decl (";" decl)*)* "}"
I guess my point is that using curly-braces and semi-colon can be quite
attractive, even in the absence of indentation rules. Personally, I hate
that OCaml has reserved the word "and".
Thanks,
PKE.
Rick R wrote:
> I rather like
> let { binding and binding and binding in EXPR}
>
> or let binding
> binding
> binding
> in EXPR
>
>
> This leaves no question in the reader's mind about the scope of the
> variables. It is explicit that all variables share the same scope,
> which is the intent here, isn't it?
>
> If you want nested levels of scope, then put another let block in the
> EXPR.
>
> This is basically Haskell syntax, perhaps I'm already showing by bias.
>
>
> On Thu, Mar 5, 2009 at 12:36 PM, Jonathan S. Shapiro <[email protected]
> <mailto:[email protected]>> wrote:
>
> Binding forms that introduce inner scopes should be distinct from
> those that merely append definitions to the current scope. I do
> understand that appending actually does introduce a new scope. The
> issue is that in one type of form the scopes end in the same place,
> where in the other they do not.
>
> I'm currently inclined to favor a syntax very similar to OCaml:
>
> let BINDING { and BINDING } in EXPR end
>
> and other forms similarly.
>
>
> Strong objections or alternatives?
> _______________________________________________
> bitc-dev mailing list
> [email protected] <mailto:[email protected]>
> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
>
>
>
> --
> We can't solve problems by using the same kind of thinking we used
> when we created them.
> - A. Einstein
--
Pål-Kristian Engstad ([email protected]),
Lead Graphics & Engine Programmer,
Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North,
Santa Monica, CA 90404, USA. Ph.: (310) 633-9112.
"Emacs would be a far better OS if it was shipped with
a halfway-decent text editor." -- Slashdot, Dec 13. 2005.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev