From: William Chesters <williamc@dai.ed.ac.uk>
To: caml-list@inria.fr
Subject: Re: speed versus C
Date: Sun, 10 Oct 1999 21:48:41 +0100 [thread overview]
Message-ID: <24949.199910102048@buckie> (raw)
In-Reply-To: <99101018244300.30629@ice>
Gerd Stolpmann writes:
> If you wanted to have a fully general substitute of closures in C (or
> assembler), you could do it as follows: For every function store a function
> pointer and an array of implicit parameters, e.g.
I'm not sure we are really connecting here. The fragment I quoted
involved a table of functions which share "implicit parameters" (the
`file' struct)---i.e., a thinly disguised C++ object, implemented in
exactly the way cfront used to do it.
(I wish I hadn't mentioned objects at all. The simpler case of a
single function pointer associated with a single implicit parameter is
common in the APIs to numerical library routines.)
> In object-oriented languages there is another way of paraphrasing
> closures.
As I said, a closure is an object with only one method.
> >(Though I'd argue that's because it sticks to
> >abstractions that "ornament" the low-level computational model without
> >"obscuring" it :-) .)
>
> I think this is exactly the point where we have different opinions.
More like, we are understanding "the low-level model" to mean
different things. I am happy to consider a function pointer plus a
persistent data record to "really be" a closure---something which one
might not realise before one was exposed to FLs, so that they enrich
and clarify one's understanding of low-level programming---whereas you
perhaps aren't?
Give me a little credit and try to understand what I say charitably
:-). I don't know what your background is, and I don't know how much
patience you have with "impressionistic" ideas. But I did once study
formal semantics, domain theory and the deep way different
computational models relate to each other in some detail, so I am
perfectly well aware of what constitutes a tight argument in this
context.
My point was simply that nearly every* feature of ocaml, however
abstract in appearance, compiles directly, and compositionally, onto
an idiom which one might well use in C or even assembler---give or
take some amount of sugar. Looking at this fact one way round, I
observe that the reason ocaml is so fast is that it mostly* stays
within the framework of the traditional computer model; looking at it
from the other direction, I note that the constructs which ocaml maps
onto the various different C idioms illuminate the "deeper meaning" of
the latter in terms of a much more abstract semantics.
* apart from GC and the ocaml classes (of which I must admit I am
slightly suspicious, because of the significant overhead in a method
call---you don't really want to use them in an inner loop)
Compare this with lazy languages, with which the whole discussion
started: they must necessarily use the traditional CPU in a pretty
contorted way to implement a basically foreign computational model.
(Graph reduction, or however you like to present it.) Compare it too
with SML/NJ, which supports continuations and therefore has to
allocate its stack frames on the heap---crazy, because continuations
aren't all that useful (corresponding most closely to a non-local
JMP), and noone seems to believe their protestations that this
implementation carries 0 performance penalty.
I contend that on the one hand stepping distinctly outside the
traditional model means slowness, and on the other that the
traditional model is not a bad one to think in, as long as your
understanding of it is enriched by experiencing and preferably using a
language like ocaml (and/or C++).
Anyway, thanks for the discussion!
Cheers,
William
next prev parent reply other threads:[~1999-10-10 21:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-03 21:35 Jan Brosius
1999-10-04 21:59 ` skaller
1999-10-05 23:22 ` chet
1999-10-06 10:22 ` skaller
1999-10-05 20:20 ` Gerd Stolpmann
1999-10-06 15:21 ` William Chesters
1999-10-06 22:49 ` Gerd Stolpmann
1999-10-07 10:26 ` Michel Quercia
1999-10-07 10:46 ` William Chesters
1999-10-07 15:48 ` Pierre Weis
1999-10-07 19:21 ` Gerd Stolpmann
1999-10-08 0:26 ` William Chesters
1999-10-10 16:27 ` Gerd Stolpmann
1999-10-10 20:48 ` William Chesters [this message]
1999-10-10 23:54 ` Alain Frisch
1999-10-11 17:58 ` William Chesters
1999-10-12 14:36 ` Ocaml Machine (was Re: speed versus C) Alain Frisch
1999-10-12 15:32 ` David Monniaux
1999-10-12 15:42 ` Alain Frisch
1999-10-11 19:32 ` speed versus C John Prevost
1999-10-11 20:50 ` Gerd Stolpmann
1999-10-12 20:07 ` skaller
1999-10-08 9:56 ` Pierre Weis
1999-10-07 15:25 ` Markus Mottl
1999-10-07 6:56 ` skaller
1999-10-07 12:37 ` Xavier Urbain
1999-10-07 22:18 ` Gerd Stolpmann
1999-10-08 19:15 ` skaller
1999-10-08 13:40 ` Anton Moscal
1999-10-06 7:58 ` Reply to: " Jens Olsson
1999-10-07 13:00 STARYNKEVITCH Basile
1999-10-08 6:57 Pascal Brisset
[not found] <Pine.LNX.4.03.9910081713230.31666-100001@post.tepkom.ru>
1999-10-10 4:51 ` skaller
1999-10-11 9:08 ` Anton Moscal
1999-10-12 13:21 Damien Doligez
1999-10-12 20:42 ` skaller
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=24949.199910102048@buckie \
--to=williamc@dai.ed.ac.uk \
--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;
as well as URLs for NNTP newsgroup(s).