Browse thread
global record
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David MENTRE <david.mentre@g...> |
| Subject: | Re: [Caml-list] global record |
Oops, forgot the caml-list.
d.
2006/7/19, David MENTRE <david.mentre@gmail.com>:
> Hello,
>
> 2006/7/19, Andreas Biegert <andreas.biegert@googlemail.com>:
> > Is
> > there a way to make the (possibly modified) parameters record globally
> > accessable throughout all modules?
>
> Define a global variable in the Par module, use it in the other modules.
>
> ==par.ml==
> type param = { mutable a: int; }
>
> let params = { a = 3; }
> ==
>
> ==foo.ml==
> let bar = Par.params.a
>
> let _ = Par.params.a <- bar + 1
> ==
>
> > This would be much more convenient
> > than having to pass the parameters record to virtually all functions
> > in my application.
>
> <personal taste>I find this purely functional approach much cleaner
> because you know where your global variables are read or modified
> directly by looking at function parameters.</personal taste>
>
> Best wishes,
> d.
>