caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Creating recursive values
@ 2005-02-07  2:54 Jonathan Roewen
  2005-02-07  3:28 ` skaller
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Roewen @ 2005-02-07  2:54 UTC (permalink / raw)
  To: caml-list

Hi,

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
	window

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.

Regards,
Jonathan Roewen


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Creating recursive values
  2005-02-07  2:54 [Caml-list] Creating recursive values Jonathan Roewen
@ 2005-02-07  3:28 ` skaller
  0 siblings, 0 replies; 2+ messages in thread
From: skaller @ 2005-02-07  3:28 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

On Mon, 2005-02-07 at 13:54, Jonathan Roewen wrote:

For functions, which 'on_drag()' is one of:

> 	let window = GroupedGraphic (
          let rec window = .
              ^^^
> 				[(MouseDrag, on_drag)] (* Where trouble begins =( *)

> 	and on_drag () = match window with

just add 'rec' keyword as shown.


-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-02-07  3:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-07  2:54 [Caml-list] Creating recursive values Jonathan Roewen
2005-02-07  3:28 ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).