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

[-- Attachment #1: Type: text/plain, Size: 2065 bytes --]

    > 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

[-- Attachment #2: Type: text/html, Size: 2764 bytes --]

  reply	other threads:[~2014-01-29 17:16 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 [this message]
2014-02-01 15:03             ` Goswin von Brederlow

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=CAN6ygOmmOWUYNzaFT7yAsysrV6SBJHt_VjzKzEynop9rY3xVNQ@mail.gmail.com \
    --to=yotambarnoy@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=goswin-v-b@web.de \
    /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).