* [Caml-list] let rec when not recursive
@ 2003-04-24 13:58 henridf
2003-04-24 14:05 ` Mike Lin
2003-04-24 17:47 ` Chris Hecker
0 siblings, 2 replies; 3+ messages in thread
From: henridf @ 2003-04-24 13:58 UTC (permalink / raw)
To: caml-list
Hi,
I have a callback function which i would like to reschedule itself into
the event queue that called it.
In order to be able to refer to the function within the body (ie, pass
'clock_tick' as argument to sched#sched_in), the only think i could think
of was to make it recursive, even though it isn't (because the
sched#sched_in call returns immediately).
Is this a perversion of the 'let rec' construct? Is there a better way to
get around it? Thanks.
hdf
let rec clock_tick() = (
...
do stuff
...
sched#sched_in ~handler:clock_tick ~t:1.0;
)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] let rec when not recursive
2003-04-24 13:58 [Caml-list] let rec when not recursive henridf
@ 2003-04-24 14:05 ` Mike Lin
2003-04-24 17:47 ` Chris Hecker
1 sibling, 0 replies; 3+ messages in thread
From: Mike Lin @ 2003-04-24 14:05 UTC (permalink / raw)
To: Henri DF; +Cc: caml-list
On Thursday, April 24, 2003, at 09:58 AM, henridf@lcavsun1.epfl.ch
wrote:
> In order to be able to refer to the function within the body (ie, pass
> 'clock_tick' as argument to sched#sched_in), the only think i could
> think
> of was to make it recursive, even though it isn't (because the
> sched#sched_in call returns immediately).
If the definition of the function refers to itself then it is
recursive. It doesn't matter if it actually invokes itself or not. So,
no, this is not a perversion of anything.
-Mike
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] let rec when not recursive
2003-04-24 13:58 [Caml-list] let rec when not recursive henridf
2003-04-24 14:05 ` Mike Lin
@ 2003-04-24 17:47 ` Chris Hecker
1 sibling, 0 replies; 3+ messages in thread
From: Chris Hecker @ 2003-04-24 17:47 UTC (permalink / raw)
To: Henri DF, caml-list
>the only think i could think
>of was to make it recursive, even though it isn't (because the
>sched#sched_in call returns immediately).
Here's how I did this same thing using LablTk a long time ago. I was
originally not removing the timer at the end of the run and tk would
eventually freak out after a bunch of runs.
let rec timer_t = ref
(let rec add_timer () = Timer.add ~ms:1
~callback:(fun () -> (try display togl with _ -> ()); timer_t :=
add_timer ()) in
add_timer ())
in
blah..
Timer.remove !timer_t
Chris
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-24 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-24 13:58 [Caml-list] let rec when not recursive henridf
2003-04-24 14:05 ` Mike Lin
2003-04-24 17:47 ` Chris Hecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox