From: John Max Skaller <skaller@ozemail.com.au>
To: Dave Mason <dmason@sarg.Ryerson.CA>
Cc: David McClain <dmcclain1@mindspring.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Evaluation Order
Date: Wed, 13 Jun 2001 03:34:11 +1000 [thread overview]
Message-ID: <3B265293.D27EA88A@ozemail.com.au> (raw)
In-Reply-To: <200106111259.IAA14288@sarg.Ryerson.CA>
Dave Mason wrote:
> > In principle, the Felix type checker would prevent this:
> > side-effects are not permitted in functions.
>
> > The reason for relaxing the rules is that it is very ugly and
> > insecure to write things like:
>
> > val x : int; // uninitialised variable!
> > fetch(&x,&state_object);
>
> > instead of
>
> > val x : int = fetch(&state_object);
>
> > I can't think of good way around this though.
> Functions *should* be able to do side-effects (unless you have a pure
> functional language),
My desire is to have a purely functional subsystem.
So I would 'say' that functions cannot have side effects.
However, Felix has procedures too, which cannot return
values. There is a reason for this.
Functions execute 'on the stack'. They may not
read input or have any side effects.
Procedures work by continuation passing.
When you call a procedure, it _returns_ control,
passing a continuation, which is immediately
resumed by the driver. When a request to read input
is encountered, control is also returned.
The driver then stores a message and resumes
the continuation. In other words, the system
is event driven transparently.
Now see below:
> I think my proposal from the weekend is better: functions can have
> side effects, but you can't use the results in a way that will bite
> you (due to order of evaluation).
That is what I am looking for. Basically,
I want some sugar, so that users can write:
val x = f();
but the implementation is actually equivalent to:
val x;
f(&x);
Note that this is implemented like this:
switch(pc) {
...
...
pc = 2;
return new f(&x);
case 2:
...
So in Felix, it is not a matter of style that procedures
returning values cannot be used 'inside' expressions:
it would greatly complicate the compiler, because it
would have to linearise expression trees 'down to'
any procedure call. Currently, expressions are
simply replaced by their C++ equivalents, and the C++
compiler can then have a go at optimising them.
BTW: I'm currently putting Felix up on sourceforge:
http://felix.sf.net
--
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-06-13 9:56 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-09 15:59 David McClain
2001-06-09 20:17 ` Brian Rogoff
2001-06-09 23:12 ` David McClain
2001-06-09 23:28 ` David McClain
2001-06-10 1:04 ` Dave Mason
2001-06-10 2:25 ` David McClain
2001-06-11 13:03 ` Dave Mason
2001-06-12 17:55 ` John Max Skaller
2001-06-13 16:54 ` Frederick Smith
2001-06-13 21:43 ` John Max Skaller
2001-06-10 1:06 ` Charles Martin
2001-06-10 2:27 ` David McClain
2001-06-10 11:18 ` Tore Lund
2001-06-10 13:11 ` Tore Lund
2001-06-10 14:31 ` John Max Skaller
2001-06-12 15:12 ` Pierre Weis
2001-06-10 10:40 ` Joerg Czeranski
2001-06-10 14:06 ` John Max Skaller
2001-06-11 12:59 ` Dave Mason
2001-06-12 17:34 ` John Max Skaller [this message]
2001-06-10 13:47 ` John Max Skaller
2001-06-10 16:47 ` Brian Rogoff
2001-06-10 17:27 ` Dave Mason
2001-06-12 16:10 ` John Max Skaller
2001-06-09 23:19 ` John Max Skaller
2001-06-10 2:44 David McClain
2001-06-10 2:48 ` Patrick M Doane
2001-06-10 5:51 ` David McClain
2001-06-10 17:59 Damien Doligez
2001-06-10 18:28 ` Dave Mason
2001-06-15 17:00 Manuel Fahndrich
2009-06-14 16:36 evaluation order Christophe Raffalli
2009-06-14 19:40 ` [Caml-list] " Jon Harrop
2009-06-14 21:12 ` Christophe Raffalli
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=3B265293.D27EA88A@ozemail.com.au \
--to=skaller@ozemail.com.au \
--cc=caml-list@inria.fr \
--cc=dmason@sarg.Ryerson.CA \
--cc=dmcclain1@mindspring.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