[nem-en] nested declarations?

Kamil Skalski kamil.skalski at gmail.com
Thu Jan 12 13:51:09 CET 2006


2006/1/12, Maurizio Colucci <maurizio.colucci at gmail.com>:
> Hello,
>
> I know nested funcions are supported in Nemerle, but are nested
> variable declarations allowed? i.e. what is the Nemerle translation

yes

> for the following ocaml code?
>
> let foo x =
>   let val1 =
>     let r =
>        r + 5
>     in
>     x + r
>   in
>   val1 + x
>

it would be
def foo (x) {
  def val1 = (
     def r = a + 5;
     x+ r
  );
  val1 + x
}

(note that there was an error in your example:  'let r = r + 5', I
used 'def r = a + 5')

I remember there was some bug with nested variables some time ago, but
I guess it is already fixed and the above code should work.


--
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list