Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Michael Walter <michael.walter@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] environment idiom
Date: 13 Dec 2004 18:08:30 +1100	[thread overview]
Message-ID: <1102921708.2768.282.camel@pelican.wigram> (raw)
In-Reply-To: <1102918715.2768.240.camel@pelican.wigram>

On Mon, 2004-12-13 at 17:18, skaller wrote:

BTW: one reason I'm very interested in the 'transparency'
and 'purity' topic is a practical matter:

> Another example is my Felix language. It has both functions
> and procedures. Functions aren't allowed to have side effects,
> yet they're not pure in the sense the result can depend
> on variables which change between (but not during) invocations.
> [This has an alarming effect on the optimiser ..]


Crudely the optimiser simply inlines everything,
perhaps an improved version will do usage checks
to cache results..

This must work fine if functions are pure.
But as noted, they're not, because they can access variables
that change with time, and so the place of calling a
function, which is related to when it is evaluated,
makes a difference.

To fix this I need to be able to do something crude
like designate a function as 'pure' -- this has been
discussed for Ocaml too.

That isn't the only possible technique, and it isn't
clear how to carry this information through for
function variables, unless the type system is involved.
EG you have two arrows:

	a -> b  pure function
	a +> b  can refer to variables

which raises questions about unification, overloading,
subtyping, etc.

However if a function isn't pure, when you evaluate
it matters .. but that doesn't tell you when to evaluate it.
Instead of saying 'strict' or 'lazy', one could annotate
function arguments:

	let f (g:lazy) (h:eager) (k:pure) x  = ..

which tells the compiler that to evaluate h 'before
the call', g precisely when needed, possibly twice
with different results, and k anytime convenient.
 
Well that seems to impact the type system too.. :)

At present I use a trick to distinguish procedures:
they have the type

	'a -> void

which prevents them being used in a context where
the sequence of evaluation is indeterminate (i.e. in
expressions). 

Well now I seem to need more than just procedures
and functions, I need at least pure and impure
functions (where impure does NOT mean side-effects,
but rather non-parametricity, which has the same
negative effect on transparency).

So I have a pragmatic interest in finding a theoretical model
that says something more about how pure/impure/lazy/eager/etc etc
code interacts: with the optimiser switched on, I'm the only
person that can predict what a Felix program will do,
and my own optimiser has caught me out several times already :)


-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  reply	other threads:[~2004-12-13  7:08 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09  2:07 HENRIKSON, JEFFREY
2004-12-09  4:47 ` [Caml-list] " Jacques Garrigue
2004-12-09  6:02   ` Michael Walter
2004-12-09 11:28     ` Jacques Garrigue
2004-12-09 20:02     ` pad
2004-12-09 23:11       ` Jacques Garrigue
2004-12-10  2:30         ` skaller
2004-12-09  9:09 ` Richard Jones
2004-12-09 13:12   ` [Caml-list] " Ville-Pertti Keinonen
2004-12-10 11:59     ` Richard Jones
2004-12-10 10:52 ` [Caml-list] " Andrej Bauer
2004-12-10 12:13   ` Richard Jones
2004-12-10 23:35     ` Jacques Garrigue
2004-12-11  2:30   ` skaller
2004-12-11 14:31     ` Andrej Bauer
2004-12-11 18:13       ` Markus Mottl
2004-12-11 23:56         ` skaller
2004-12-12  2:36           ` William Lovas
2004-12-12  5:33             ` skaller
2004-12-12 19:09               ` Michael Walter
2004-12-13  0:48                 ` skaller
2004-12-13  2:03                   ` Michael Walter
2004-12-13  2:05                     ` Michael Walter
     [not found]                       ` <877e9a170412121844b633bb8@mail.gmail.com>
2004-12-13  2:45                         ` Michael Walter
2004-12-13  6:18                           ` skaller
2004-12-13  7:08                             ` skaller [this message]
2004-12-13  9:56                             ` Michael Walter
2004-12-13 12:59                               ` skaller
2004-12-13  8:56                           ` Thomas Fischbacher
2004-12-13  9:21                             ` Jacques Garrigue
2004-12-13 10:05                               ` Michael Walter
2004-12-13 10:29                                 ` Thomas Fischbacher
2004-12-13 21:16                                   ` Michael Walter
2004-12-13 10:20                               ` Thomas Fischbacher
2004-12-13 12:09                                 ` Jacques Garrigue
2004-12-13 12:48                                   ` Thomas Fischbacher
2004-12-13 14:09                                   ` skaller
2004-12-13 21:39                                     ` Michael Walter
2004-12-13 13:22                                 ` skaller
2004-12-13 16:54                                   ` Marcin 'Qrczak' Kowalczyk
2004-12-13 18:44                                   ` Thomas Fischbacher
2004-12-13 10:11                             ` Michael Walter
2004-12-13 11:46                             ` skaller
2004-12-13  5:41                     ` skaller
2004-12-13  9:29                       ` Michael Walter
2004-12-13 12:30                         ` skaller
2004-12-13 13:49                           ` Martin Berger
2004-12-12 23:03           ` Thomas Fischbacher
2004-12-13  1:26             ` skaller
2004-12-13  8:37               ` Thomas Fischbacher
2004-12-13 10:53                 ` skaller
2004-12-13 11:38                   ` Martin Berger
2004-12-13 13:33                     ` skaller
2004-12-13 12:01                   ` Thomas Fischbacher
2004-12-13 13:41                     ` skaller
2004-12-11 23:29       ` skaller
2004-12-12  0:21         ` Jacques Carette

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=1102921708.2768.282.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=michael.walter@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