clarification on single assignment

Robert Virding <>
Wed Nov 22 11:38:00 CET 2000


Ulf Wiger <> writes:
>
>I read a paper on SAC (Single Assignment C):
>
>"Multiple assignments within a block are permitted, i.e. an identifier
>may be used more than once on the left-hand side of an assignment.
>This does not contradict the functional paradigm since multiple
>assignments are equivalent to nested (non-recursive) LET expressions.
>Thus, the scope of an identifier simply extends over the sequence of
>statements between two consecutive assignments to it. With this
>interpretation in mind, it is perfectly legitimate to call SAC a
>single assignment language. The Chuch Rosser property can nevertheless
>be guaranteed at the level of entire blocks if they are taken as basic
>units of strictly sequential computations."
>
>http://www.informatik.uni-kiel.de/~sacbase/papers/sac-overview-norwich-94.ps.gz
>
>I don't know exactly what all that means. I'm trying to figure out if
>its anything more than a cop-out. It did strike me, however, that if
>they were right (assuming the message is that SAC's version of single
>assignment is as good as anybody else's), it ought to work for Erlang
>too, since all Erlang functions are basic units of strictly sequential
>computations.

No, it will not work in Erlang.  The trouble is that Erlang has no
variable scope and in SAC they relied on this to be able to call it
single-assignment.  So in SAC (whatever the syntax is):

    x = <expr1>;
    <expr2>;
    x = <expr3>;
    <expr4>;

would have the same semantics as

    let x = <expr1> in
        <expr2>
        let x = <expr3> in
            <expr4>

This works because of variable scoping.  This also means that there are 
no problems with assigning variables in multiple branches.

Of course, if you want we could always add proper variable scoping. :-)

>Thus, we can reuse variable names in a function and lose nothing.
>It also opens up for wonderful operators like ++ (oops! we already
>have that) +=, =+ etc.  ;)

	Robert





More information about the erlang-questions mailing list