[erlang-questions] Simple Erlang Recommendation (last returned value)

Jesper Louis Andersen <>
Mon Jul 28 12:10:51 CEST 2008


On Mon, Jul 28, 2008 at 2:47 AM, Richard A. O'Keefe <> wrote:

> Also, functional language with explicit 'let' allow
>        let val x = 1 in
>        let val x = x + 1 in
>        x+1 end end
> (SML) or

This is infected with Ocaml syntax style :) The SML way would be:

let
  val x = 1
  val x = x + 1
in
  x + 1
end

But at least one SML compiler has a warning with this style of coding
since you are shadowing the 'x' value and it quickly becomes rather
hard to follow what def-point is meant for each use (To the
non-SML'ers, let .. in .. end works somewhat like Schemes LET*). With
SML beginners, you often see "imperative" style code where the
let-blocks evaluation order is used to force imperative code while a
more functional solution is apparent to the experienced.

What the let-binding tends to be used for is to declare a number of
local functions (Which may be recursive) and then gradually combine
these into more advanced functions, of which the last is called in the
body of the binding.



More information about the erlang-questions mailing list