From: brogoff@speakeasy.net
To: "Correnson Loïc" <Loic.Correnson@trusted-logic.fr>
Cc: Timo.Tapiola@tietoenator.com, Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Function forward declaration?
Date: Tue, 6 Apr 2004 10:39:26 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0404061024550.11492@grace.speakeasy.net> (raw)
In-Reply-To: <00cf01c41bd6$391b53a0$0203a8c0@hoedic>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1325 bytes --]
On Tue, 6 Apr 2004, [iso-8859-1] Correnson Loïc wrote:
> b) You can also define *real* forward function by using references (already
> suggested)
> However, you may loose polymorphism, if any, due to (_a ->_b) ref types.
You may sidestep this issue by rolling your own refs using the explicit
polymorphism on record fields, sketched below:
type fwd_ref = { mutable f : 'a 'b . 'a -> 'b }
module Module1 = struct
let forward_g = { f = (fun x -> failwith "forward_g") }
let f = forward_g.f
end
module Module2 = struct
let g = Module1.f
let _ = Module1.forward_g.f <- g
end
and of course you can make it as pretty (yeah, I know, dressing up a pig)
as refs if you wish.
There was a discussion of this a looooong time ago, in the context of supporting
polymorphic recursion in the language, and I believe it was mentioned that some
experimental Caml compiler had a forward declaration capability. It seems like a
good idea, and I wonder why it hasn't made it into the language, as this is a
FAQ and a language blemish.
-- Brian
-------------------
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
next prev parent reply other threads:[~2004-04-06 17:39 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-06 12:14 Timo.Tapiola
2004-04-06 12:20 ` Andrew Birkett
2004-04-06 12:37 ` Remi Vanicat
2004-04-06 13:00 ` Issac Trotts
2004-04-06 12:53 ` Correnson Loïc
2004-04-06 15:14 ` skaller
2004-04-06 17:39 ` brogoff [this message]
2004-04-06 17:53 ` Richard Jones
2004-04-06 19:28 ` Marcin 'Qrczak' Kowalczyk
2004-04-06 22:37 ` Jon Harrop
2004-04-07 2:18 ` skaller
2004-04-07 6:01 ` Nicolas Cannasse
2004-04-07 7:31 ` Marcin 'Qrczak' Kowalczyk
2004-04-07 16:40 ` brogoff
2004-04-07 13:52 ` skaller
2004-04-07 14:15 ` Richard Jones
2002-01-03 15:21 ` Issac Trotts
2004-04-07 15:51 ` skaller
2004-04-07 16:41 ` Richard Jones
2004-04-07 17:31 ` Remi Vanicat
2004-04-07 17:36 ` Richard Jones
2004-04-07 17:54 ` Marcin 'Qrczak' Kowalczyk
2004-04-07 19:27 ` skaller
2004-04-07 20:24 ` Christopher Dutchyn
2004-04-07 18:04 ` Benjamin Geer
2004-04-07 19:21 ` skaller
2004-04-07 16:52 ` Shawn Wagner
2004-04-07 17:26 ` Basile Starynkevitch
2004-04-07 17:46 ` Marcin 'Qrczak' Kowalczyk
2004-04-07 18:03 ` Kenneth Knowles
2004-04-07 18:44 ` Christopher Dutchyn
2004-04-07 14:24 ` Ville-Pertti Keinonen
2004-04-07 15:12 ` skaller
2004-04-06 12:58 ` Jean-Christophe Filliatre
2004-04-06 17:26 ` Christopher Dutchyn
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=Pine.LNX.4.58.0404061024550.11492@grace.speakeasy.net \
--to=brogoff@speakeasy.net \
--cc=Loic.Correnson@trusted-logic.fr \
--cc=Timo.Tapiola@tietoenator.com \
--cc=caml-list@inria.fr \
/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