On Thu, 2006-08-24 at 09:49 -0700, Erick Tryzelaar wrote:
> skaller wrote:
>  
> I really think that something like this would be the simplest solution. 
> And technically, wouldn't it decompose from this:
> 
> proc f(x:int): int {
>   return x + 1;
> }

> Into this:
> 
> proc f(x:int) (px:int) {
>   *px = x + 1;
> }

You should note this is only one possibility. Another is:

side_effect fun f(x:int): int { .. }

and there are several more :)

In general, a 'function' can:

* depend on constants in its environment or not
* depend on variables in its environment of not
* depend on a variable in the callers environment 
  via a pointer argument
* modify an environment variable
* modify a caller variable via a pointer

The first case is already optimised: if no part
of the environment is used, the function can be
modelled as a "C" function without any thread frame 
pointer being passed.

However the dependence on environmental variables can
be annotated in the type .. variable by variable!
This is very precise:

        fun: A -> B depending on x,y modifying z

but interestingly, whilst this determines how far
we can move the call, without changing the semantics,
it doesn't determine the _correct_ place to do the call!
Given:

        var x = 1;
        print x;
        x = 2;

we expect to print 1: the call must be done fairly
eagerly. But here:

        var i = 0;
        while { i < 10 } { ..++i; }

we had better evaluate i < 10 lazily. In this case the
notation { .. } ensures lazy evaluation. But more
generally, what would you define as the meaning
of an expression with interacting side effects?

It isn't enough to say "eager evaluation" because as I 
pointed out before that defeats:

        cond? then_expr : else_expr

where you have to evaluate lazily.

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


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to