ietf-openproxy
[Top] [All Lists]

P: single assignment semantics

2003-10-27 14:41:44


I'd like to discuss a problem with assignment semantics in P. I am
curious what specific solutions other languages in similar domains,
including IRML, provide (if any).


IIRC, Geetha Manjunath spotted an important issue with P: Current
draft says that assignment is, essentially a macro. The value of a
name is a value of an expression and the time of use, not at the time
of assignment:

        name := foo(bar);
        if (name) {
                // A
        }

        ...

        if (not name) {
                // B
        }

Using the macro semantics, both A and B code pieces may be executed if
foo(bar) changes its value between the two if-statements. This macro
semantics allows for simple and/or efficient implementation. The
interpreter (in a broad sense) does not have to keep the value of
foo(bar) around between the if-statements. If that value is large
(e.g., a response body) such optimizations could be crucial.

On the other hand, macros are confusing for programmers, especially
because it is often difficult to know whether the named expression can
be changed. Assume, for example, that name is a response
body-dependent expression and code A above executes a callout service
on the response headers. By the time the service call completes, the
processor may read a few more chunks of that response body and the
value of the named expression can change. A simpler example would be:

        current_time := Time.now();     // interpreted in the morning
        ...
        if (current_time.isEvening()) { // can this become true?
                ...
        }


A different option (let's call it "immediate constant assignment")
exists: We can require the value of the expression at the time of the
assignment to be stored under the provided name and never change. This
means that some unused expressions would be computed and [very] large
values would have to be stored.

A yet another option (let's call it "lazy constant assignment")
exists: We can require the value of the expression at the time of the
first use (rather than first assignment) to be stored under the
provided name and never change after that. This option has an
advantage over immediate constant assignment in that unused
expressions are not evaluated, but it still has to store [very] large
values if an expression is used more than once.


While IRML does not have assignments, it does evaluate expressions. I
wonder if there is an implicit or explicit guarantee that the same
property is evaluated to the same value before and after a delay (such
as service execution). Does IRML assume that all properties are known
and "constant" just before the script is interpreted?

Thanks,

Alex.



<Prev in Thread] Current Thread [Next in Thread>