Browse thread
[Caml-list] class variables?
-
Michael Vanier
- Warp
-
Maxence Guesdon
- Alain Frisch
- Andreas Rossberg
[
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: | Andreas Rossberg <rossberg@p...> |
| Subject: | Re: [Caml-list] class variables? |
Maxence Guesdon wrote: > > *But* if class foo has parameters, then the expressions before the 'objet' keyword are evaluated at > each creation of a new instanciation, so in the following code > > class foo () = > let my_list = [ "foo" ; "bar"] in > object > ... > end > > let t = new foo > let u = new foo You probably meant let t = new foo () let u = new foo () > t and u are two objects which don't share the list my_list. Right, but you can push the lambda below the let, much like for function definitions: class foo = let my_list = [ "foo" ; "bar"] in fun arg -> object ... end This should do what Michael wants. - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids; I mean if Pac Man affected us as kids, we would all be running around in darkened rooms, munching magic pills, and listening to repetitive electronic music." - Kristian Wilson, Nintendo Inc. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr