From: Goswin von Brederlow <goswin-v-b@web.de>
To: "'OCaml List'" <caml-list@inria.fr>
Subject: Re: [Caml-list] Recursive subtyping issue
Date: Tue, 02 Mar 2010 11:22:04 +0100 [thread overview]
Message-ID: <87r5o3hvlf.fsf@frosties.localdomain> (raw)
In-Reply-To: <004101cab97b$a0a19360$e1e4ba20$@romulus.metastack.com> (David Allsopp's message of "Mon, 1 Mar 2010 20:12:57 -0000")
"David Allsopp" <dra-news@metastack.com> writes:
> Goswin von Brederlow wrote:
>> "David Allsopp" <dra-news@metastack.com> writes:
>>
>> > external foo_of_bar : bar -> foo = "%identity"
>> >
>> > in *both* the .ml and .mli file for the module in question. I'm
>> virtually certain that ocamlopt eliminates calls to the %identity
>> primitive.
>>
>> Where is that documented?
>
> The use of external and its benefit in exported signatures is documented in
> Chapter 18 of the manual.
>
> I believe I became aware of the %identity special handling as a side-effect
> of the discussion in
> http://caml.inria.fr/pub/ml-archives/caml-list/2007/04/200afc54d9796dbb7a8d7
> 5bef70f2496.en.html.
>
> If you look in asmcomp/cmmgen.ml you'll see what I think is the elimination
> of Pidentity calls in the code generator.
Meaning it is not documented. :(
>> I would have written
>>
>> let foo_of_bar (x : bar) = (x :> foo)
>
> We're solving two different problems, I think (as you're assuming that bar
> can be constrained to type foo) - I'm assuming that all type constraining is
> done in the signature of the interface so, without %identity I would simply
> have put [let foo_of_bar x = x] of type 'a -> 'a in my module... and then
> constrained it as [val foo_of_bar : bar -> foo] in the signature.
>
> It is possible that ocamlopt can recognise (obvious) identity functions as
> well, but that's just speculation on my part as I haven't looked.
It probably won't detect it as identity function but it probably always
inlines it and thereby eliminates it. I hope.
MfG
Goswin
next prev parent reply other threads:[~2010-03-02 10:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-27 1:52 Guillaume Yziquel
2010-02-27 6:38 ` [Caml-list] " Andreas Rossberg
2010-02-27 10:25 ` Guillaume Yziquel
2010-02-27 11:49 ` Goswin von Brederlow
2010-02-27 13:11 ` Guillaume Yziquel
2010-02-27 16:52 ` Andreas Rossberg
2010-02-27 18:10 ` Guillaume Yziquel
2010-02-27 19:52 ` Guillaume Yziquel
2010-02-27 20:32 ` Guillaume Yziquel
2010-03-01 10:55 ` Stéphane Glondu
2010-03-01 11:21 ` Guillaume Yziquel
2010-03-01 12:28 ` Stéphane Glondu
2010-03-01 12:49 ` David Allsopp
2010-03-01 13:06 ` Guillaume Yziquel
2010-03-01 12:49 ` David Allsopp
2010-03-01 13:28 ` Goswin von Brederlow
2010-03-01 20:12 ` David Allsopp
2010-03-02 10:22 ` Goswin von Brederlow [this message]
2010-03-01 13:33 ` Guillaume Yziquel
2010-03-01 20:18 ` David Allsopp
2010-02-28 9:54 ` Goswin von Brederlow
2010-02-28 11:08 ` Guillaume Yziquel
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=87r5o3hvlf.fsf@frosties.localdomain \
--to=goswin-v-b@web.de \
--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).