From: Richard Jones <rich@annexia.org>
To: John Prevost <j.prevost@gmail.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Functors and classes
Date: Tue, 3 Aug 2004 17:42:29 +0100 [thread overview]
Message-ID: <20040803164229.GA26451@annexia.org> (raw)
In-Reply-To: <d849ad2a04080309237290a1d9@mail.gmail.com>
On Tue, Aug 03, 2004 at 12:23:07PM -0400, John Prevost wrote:
> Yes, that's the same problem I'm seeing. I think it *might* be
> possible to get around it by using a connection type with type
> parameters. Maybe. I'll investigate more in a few hours.
>
> This is an upsetting problem, but I believe that it's known that there
> are some drawbacks to mixing classes and functors. (And, well, if
> it's not, it should be now.) Anyway, we'll see what can be done.
>
> If one of the approaches I'm thinking of would work, it might either
> suggest a rather painful (and non-obvious) change to the Dbi API, or
> it might be possible to define a functor or simple wrapper to turn a
> Dbi module into a Dbi' module that works well for this.
>
> And maybe someone who's done a lot of work with classes and modules
> will mention a really nifty solution. :)
One "solution" I've come up with is to add a functional interface to
Dbi_postgres. ie: adding this to the end:
let connect ?host ?port ?user ?password database =
new connection ?host ?port ?user ?password database
let close (dbh : connection) = dbh#close ()
let closed (dbh : connection) = dbh#closed
let commit (dbh : connection) = dbh#commit ()
let ping (dbh : connection) = dbh#ping ()
let rollback (dbh : connection) = dbh#rollback ()
then I've changed the functor input signature to:
module type DbiDriverT = sig
type connection
val connect : ?host:string -> ?port:string ->
?user:string -> ?password:string -> string ->
connection
val close : connection -> unit
val closed : connection -> bool
val commit : connection -> unit
val ping : connection -> bool
val rollback : connection -> unit
end
with appropriate changes to the functor itself to use the functions
instead of methods.
It works, but it's not particularly elegant, and a better solution
would be welcome.
Rich.
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
'There is a joke about American engineers and French engineers. The
American team brings a prototype to the French team. The French team's
response is: "Well, it works fine in practice; but how will it hold up
in theory?"'
-------------------
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
prev parent reply other threads:[~2004-08-03 16:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-03 12:02 Richard Jones
2004-08-03 12:10 ` Richard Jones
2004-08-03 13:17 ` Richard Jones
2004-08-03 15:06 ` John Prevost
2004-08-03 15:12 ` Richard Jones
2004-08-03 15:27 ` John Prevost
2004-08-03 15:28 ` John Prevost
2004-08-03 19:57 ` brogoff
2004-08-03 22:05 ` brogoff
2004-08-03 23:24 ` John Prevost
2004-08-03 15:50 ` Richard Jones
2004-08-03 16:23 ` John Prevost
2004-08-03 16:42 ` Richard Jones [this message]
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=20040803164229.GA26451@annexia.org \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
--cc=j.prevost@gmail.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