English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Creating recursive values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-07 (02:54)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] Creating recursive values

The title might not be quite correct, but I don't really know how to
describe it. Anyways, I'm trying to create a value which references
another value that has to reference the original value.

let make_window origin bounds title =
	let (x,y) = origin
	and (w,h) = bounds in
	let window = GroupedGraphic (
		x, y, [
			InteractiveGraphic (
				[(Up,Graphic (Rectangle (0,0,w+8,h+8), control_brush, control_pen))],
				[(MouseDrag, on_drag)] (* Where trouble begins =( *)
			Graphic (Rectangle (4,4,w,h), white_brush, control_pen);
	and on_drag () = match window with
	| GroupedGraphic (x,y,lst) -> GroupedGraphic (x+mouse.x,y+mouse.y,lst);
	redraw_gui () in

I don't really want to have to deconstruct the window, and reconstruct
it again. I tried to make a start on that, and it was very messy.
There _has_ to be a better way to solve this recursive problem.

Jonathan Roewen