0 people like it.

Static scope for immutable variables

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
module Test1 =
   let x = 5
   let get_clo() = fun () -> x

module Test2 =
   let x = 10
   let f = Test1.get_clo()

Test2.f() /// 5
val x : int

Full name: Script.Test1.x
val get_clo : unit -> unit -> int

Full name: Script.Test1.get_clo
val x : int

Full name: Script.Test2.x
val f : (unit -> int)

Full name: Script.Test2.f
module Test1

from Script
module Test2

from Script
Raw view Test code New version

More information

Link:http://fssnip.net/bk
Posted:14 years ago
Author:
Tags: