From: Toby Moth <tm1@cise.npl.co.uk>
To: caml-list@inria.fr, junzhang@ccrl.nj.nec.com
Subject: Re: forward function definitions
Date: Mon, 14 Jun 1999 11:34:26 +0100 (BST) [thread overview]
Message-ID: <199906141034.LAA24581@squall.cise.npl.co.uk> (raw)
> From Pierre.Weis@inria.fr Sat Jun 12 00:13:57 1999
> Date: Wed, 9 Jun 1999 14:38:22 -0400 (EDT)
> From: Junbiao Zhang <junzhang@ccrl.nj.nec.com>
> X-Sender: junzhang@flame
> To: caml-list@inria.fr
> Subject: forward function definitions
> MIME-Version: 1.0
> Sender: Pierre.Weis@inria.fr
>
> Hi,
>
> We're developing a fairly large system with multiple function
> definitions. It's inevitable that some functions may call other functions
> defined later(may not even be recursive calls as in the case of
> Sys.Signal_handle). My question is: how do I solve such a problem which is
> extremely trival in other languages? Thanks.
>
Can't you just wrap up your deferred functions inside a mutable array or
an object ?
e.g.
type 'a defer = { mutable exec : 'a }
let defer_fun = { exec = fun i -> print_int i }
let eval = defer_fun.exec;;
eval 3;;
defer_fun.exec <- fun i -> print_int ( i * 2 );;
eval 3;;
etc.
or
class defer =
object
val mutable exec = fun i -> print_int i
method update new_fun = exec <- new_fun
method exec = exec
end
....
I picked types here that match the types used in your example.
t
next reply other threads:[~1999-06-14 15:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-14 10:34 Toby Moth [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-06-09 18:38 Junbiao Zhang
1999-06-14 10:55 ` Sven LUTHER
1999-06-14 16:17 ` Pierre Weis
1999-06-16 13:03 ` luther sven
1999-06-16 20:55 ` Pierre Weis
1999-06-17 8:46 ` Sven LUTHER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199906141034.LAA24581@squall.cise.npl.co.uk \
--to=tm1@cise.npl.co.uk \
--cc=caml-list@inria.fr \
--cc=junzhang@ccrl.nj.nec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox