caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Yotam Barnoy <yotambarnoy@gmail.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Purity in ocaml
Date: Sat, 1 Feb 2014 16:03:05 +0100	[thread overview]
Message-ID: <20140201150305.GC1783@frosties> (raw)
In-Reply-To: <CAN6ygOmmOWUYNzaFT7yAsysrV6SBJHt_VjzKzEynop9rY3xVNQ@mail.gmail.com>

On Wed, Jan 29, 2014 at 12:16:12PM -0500, Yotam Barnoy wrote:
>     > I'm not sure what you mean. Are you asking for purity annotations in
> the
> 
> >  > syntax? It's always possible to do
> > > let f : pure 'a -> 'a = fun x -> ...
> > > as one option, but I agree that having some shortcut in the syntax would
> > be
> > > useful. I'm open to suggestions. Regarding first class modules, those are
> > > in the same category as higher-order functions that cannot be inferred --
> > > they must be annotated.
> >
> > "pure" would be a new keyword, like "type"?
> >
> >
> It could be. Maybe it should be let_pure, let_hpure, let_st or some such
> thing. It requires further thought, but in general I think it's easier to
> add keywords to the type domain than it is to the syntax domain.
> 
> 
> I think this can be somewhat mitigated by cross module optimization.
> > The compiler could record in the .cmi file that the function is
> > annotated as impure but happens to be pure at this point in time. The
> > type checker would check that impure is correct with its usage but the
> > optimizer would optimize for purity.
> >
> >
> That's basically what I meant to say.
> 
> I guess the issue here is that I'm proposing 2 features: purity as a
> language feature and cross-module purity optimizations as an optimization.
> These 2 features overlap, since we can't infer purity in a function
> container -- we can only do so for a function itself. So if you want to
> optimize a function container (ie. a function within another type) you have
> to annotate it yourself, at which point it becomes a language feature.
> 
> Cross-module optimization (such as cross-module inlining) is another place
> where the interface boundary is broken -- you're assuming things about the
> workings of the another module that aren't guaranteed to be right if you
> load that module dynamically. That means that the dynamic loader has to
> check that the other module hasn't changed from the version that was
> compiled against. This scheme would work for purity as well, which means
> that there isn't really a big problem -- at least no bigger than
> cross-module inlining, which is a must-have feature for performance.
> 
> Yotam

Cross-module optimization and dynamic loading are somewhat opposite
concepts. Optimizing with infered purity only works with static
linking. Dynamic linking will have to limit itself to the annotated
types to be future proove.

MfG
	Goswin

      reply	other threads:[~2014-02-01 15:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20 20:45 Yotam Barnoy
2014-01-20 21:08 ` Siraaj Khandkar
2014-01-20 21:16   ` Yotam Barnoy
2014-01-20 21:31     ` Siraaj Khandkar
2014-01-20 21:43       ` Yotam Barnoy
2014-01-20 22:55         ` Siraaj Khandkar
2014-01-21  1:37           ` Yotam Barnoy
2014-01-21  9:49 ` Goswin von Brederlow
2014-01-21 15:27   ` Yotam Barnoy
2014-01-23  9:20     ` Goswin von Brederlow
2014-01-23  9:35       ` Arnaud Spiwack
2014-01-27  9:32         ` Goswin von Brederlow
2014-01-28  9:21           ` Arnaud Spiwack
2014-02-01 14:52             ` Goswin von Brederlow
2014-02-03  9:20               ` Arnaud Spiwack
2014-01-23 18:18       ` Yotam Barnoy
2014-01-27  9:46         ` Goswin von Brederlow
2014-01-29 17:16           ` Yotam Barnoy
2014-02-01 15:03             ` Goswin von Brederlow [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=20140201150305.GC1783@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    --cc=yotambarnoy@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;
as well as URLs for NNTP newsgroup(s).