caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Krishnaswami, Neel" <neelk@cswcasa.com>
To: "'William Harold Newman'" <william.newman@airmail.net>,
	"'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: Re: [Caml-list] functors with style?
Date: Mon, 19 Nov 2001 13:32:12 -0500	[thread overview]
Message-ID: <B1E4D3274D57D411BE8400D0B783FF32A8D5EA@exchange1.cswv.com> (raw)

William Harold Newman [mailto:william.newman@airmail.net] wrote:
> 
> If I did use explicit functor expressions everywhere, it'd be readable
> enough: if my intent is make the things exactly parallel, then using
> the explicit functor expressions everywhere would make that obvious,
> so I'd be happy. But because my previous closest approach to functors
> was using templates in g++, I'm predisposed to worry about the
> compiler emitting multiple copies of the functor expansion if I don't
> give the functor expansion a home in a particular file. Is that an
> issue in Ocaml?

If I understand the papers that the people at INRIA wrote, 
there is no such template-expansion-like problem in Ocaml.

A functor is compiled to what is essentially a function that
takes a record as an argument (the module it receives as an
argument), and returns a record of functions and values. So
code generation happens only once for each functor, and each
functor application takes a very small amount of memory at
link time.

A lot of the issues surrounding functors become much clearer
when you get an operational model for how it works: think of
the ML module language as a small functional language, with
functors mapping to lambdas and functor applications mapping
to function applications. Then your intuition about how
(for example) closures are represented can guide you towards
understanding how modules and functors work. 

When I got this I was seriously impressed with how elegantly
it all works out. (Or as we said in my native South Carolina:
Them ML hackers sure are pretty smart, ain't they? :)

--
Neel Krishnaswami
neelk@cswcasa.com
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-11-19 19:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-19 18:32 Krishnaswami, Neel [this message]
2001-11-19 22:10 ` Shivkumar Chandrasekaran
2001-11-20 16:48   ` Brian Rogoff
     [not found] <9td4tb$csv$1@qrnik.zagroda>
2001-11-20 12:26 ` Marcin 'Qrczak' Kowalczyk
  -- strict thread matches above, loose matches on Subject: below --
2001-11-19 16:32 William Harold Newman
2001-11-19 19:31 ` Francisco Valverde Albacete

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=B1E4D3274D57D411BE8400D0B783FF32A8D5EA@exchange1.cswv.com \
    --to=neelk@cswcasa.com \
    --cc=caml-list@inria.fr \
    --cc=william.newman@airmail.net \
    /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;
as well as URLs for NNTP newsgroup(s).