caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Alexander Bottema" <Alexander.Bottema@mathworks.com>
To: <caml-list@inria.fr>
Subject: RE: [Caml-list] strict?
Date: Thu, 3 Aug 2006 08:29:23 +0100	[thread overview]
Message-ID: <B82387C4FEE3D84FAD99B25A2F12F6EF3DCC62@message-uk.ad.mathworks.com> (raw)

When writing real compilers, strictness is not that interesting. What we
focus on is whether a function is side-effect free or program-effect
free. Side-effect free basically practically means not doing I/O and
program effect free practically means that we don't write to "unknown"
locations in the heap/memory.

We then allow certain transformations based on whether functions are
side-effect free or program-effect free. You can probably imagine other
categories as well. After all, it is what kind of
optimizations/transformations that you'd like to do that gives your
domain of parameters to control them.

When I learned the concept of strictness it was in the context of pure
functional programming. For me the definition was mostly there to
distinguish non-strict functions, such as if(e,t,f) from other
functions. Bottom encodes essentially two different things,
non-termination or "domain error". The non-termination aspect is crucial
for non-strict functions such as if, since the non-termination of 't' or
'f' may not imply that if() itself will not terminate. However, in real
compiler design, the number of non-strict functions is very small and
usually built-ins. However, this is of course not true if you implement
lazy functional programming languages where basically everything is
non-strict.

Alexander

-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of skaller
Sent: Thursday, August 03, 2006 07:13 AM
To: O'Caml Mailing List
Subject: [Caml-list] strict?

I'm looking for a pair of concepts such as

nice function/transparent expression

which allow an arbitrary choice of evaluation strategy.

A nice function is basically one like 'sin' which is
total, has no side effects, depends only on its arguments,
and always returns a value. I think this is basically
'total, pure and strict'.

A transparent expression is one which can be evaluated
at any time, anywhere. For example 'sin 1.0' is the same
no matter when and where it is evaluated. More or less
an expression is transparent if it is a constant or
application of nice functions to transparent arguments.

The idea is basically to know when a compiler can choose
the evaluation strategy based on performance, without
worrying that this will change semantics. More precisely
my translator *already* does this .. and I want to know
when this is justified (so I can figure out how to
give the programmer enough annotations and control
to get the result they want, and be able to reason
about their code).

Note I use the word 'function' in the C (or Ocaml) sense here.
Clearly the Wikipedia definition of strict:

	f(bottom) = bottom

is rubbish when applied to a mathematical function like 'sin', 
since bottom isn't a valid argument, but it makes sense
for 'sin' in the programming language sense.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


             reply	other threads:[~2006-08-03  7:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03  7:29 Alexander Bottema [this message]
2006-08-03 20:56 ` skaller
2006-08-04 18:03   ` Alan Falloon
2006-08-05  1:19     ` skaller
  -- strict thread matches above, loose matches on Subject: below --
2006-08-03  5:13 strict? skaller
2006-08-03  7:08 ` [Caml-list] strict? Francis Dupont
2006-08-03 20:17   ` 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=B82387C4FEE3D84FAD99B25A2F12F6EF3DCC62@message-uk.ad.mathworks.com \
    --to=alexander.bottema@mathworks.com \
    --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).