Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] class variables?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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