[erlang-questions] some language changes

ok ok@REDACTED
Tue Jun 5 03:26:57 CEST 2007


On 5 Jun 2007, at 9:31 am, Kostis Sagonas wrote:
> Of course we are approaching issues of taste here, but something like
>
>    foo(A) ->
>       let B =
>          let
> 	   A = A + 1
>          in
> 	   bar(A)
>          end,
>       in
>          baz(A, B)
>       end.
>
> is obviously considerably more verbose, but not necessarily harder (to
> write or understand) than:
>
>    foo(A) ->
>       A1 = A + 1,
>       B = bar(A1),
>       baz(A1, B).

I presume this was written with tongue in cheek, because the
two are NOT equivalent.  The first version is equivalent to
	foo(A) -> baz(A, bar(A+1)).
the second version is equivalent to
	foo(A) -> A1 = A+1, baz(A1, bar(A1)).
If the two versions were supposed to be equivalent, then Kostas has
clearly demonstrated that a version that re-uses a variable name IS
harder to write correctly than what we have now.

For what it's worth, in my experimental "Haskell-ish" syntax for Erlang
these examples would be

	foo A =
	    let B = (let A = A + 1 in bar A)
	     in baz A B

and
	foo A =
	    let A1 = A + 1,
                 B  = bar A1
              in baz A1 B

respectively.  (And no, this is NOT indentation-based syntax.)



More information about the erlang-questions mailing list