From: Brian Rogoff <bpr@bpr.best.vwh.net>
To: Shivkumar Chandrasekaran <shiv@ece.ucsb.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] functors with style?
Date: Tue, 20 Nov 2001 16:48:14 +0000 (GMT) [thread overview]
Message-ID: <Pine.BSF.4.10.10111201634260.58194-100000@bpr.best.vwh.net> (raw)
In-Reply-To: <3B7E6820-DD3A-11D5-9119-003065BDAA76@ece.ucsb.edu>
On Mon, 19 Nov 2001, Shivkumar Chandrasekaran wrote:
> On Monday, November 19, 2001, at 10:32 AM, Krishnaswami, Neel wrote:
> > 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.
>
> Which of course is a problem at the "small-scale". For example I would
> like to develop a functor that is generic over the representation of
> reals (float32_elt, float64_elt, fixed_point, etc.). But now if I
> instantiate it for float64_elt and do arithmetic over float64_elt even
> simple operations will be looked-up at run-time leading to a terrible
> performance loss.
Indeed, I find that this very issue has annoyed me for many years. When I
first started playing with C++ I was involved in scientific computing and
I was less interested in the OO features than I was in overloading,
templates, and operator redefinition. I'd actually prefer the C++ style
expansion in the case you describe above, and in many others.
The other issue I have with functorial programming is the inability to
have types and functor applications in a recursive relationship, but this
is a well known problem and I think people at INRIA are working on it.
> Ideally I would prefer it if the compiler allowed the programmer to
> decide which functor applications lead to compile-time code generation
> and which are through dictionary-passing.
There's also an evil fact that's unkown to many people, namely that
DEC^H^H^HCompaq^H^H^H^H^H^H, ummm, HP?, has a patent which may cover
some helpful techniques. DEC had implemented their own Ada 83 compiler,
and, unlike C++ templates, Ada generics can be implemented by sharing as
well as by "macro expansion", and some of the DEC implementors had
patented a scheme which did both sharing and expansion. I'm not sure if
this matters, but I can try and find the reference if anyone is really
interested.
-- Brian
-------------------
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
next prev parent reply other threads:[~2001-11-20 20:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-19 18:32 Krishnaswami, Neel
2001-11-19 22:10 ` Shivkumar Chandrasekaran
2001-11-20 16:48 ` Brian Rogoff [this message]
[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=Pine.BSF.4.10.10111201634260.58194-100000@bpr.best.vwh.net \
--to=bpr@bpr.best.vwh.net \
--cc=caml-list@inria.fr \
--cc=shiv@ece.ucsb.edu \
/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