Unification, comparison [correction]
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Fri Jan 6 00:47:02 CET 2006
A minor correction:
David Hopwood wrote:
> For example, suppose that the Oz source contains an equality test
> "<variableA> == <expressionB>", where expression evaluates to <valueB>.
> Using pseudo-C notation, this would be compiled to a primitive
> "variableEqualsValue(&variableA, valueB)":
>
> bool variableEqualsValue(variable *pvarA, value *pvalB) {
> value *pvalA = derefVariable(pvarA); /* may block if undetermined */
> if (pvalA == pvalB) return true;
>
> if (valueEqualsValue(pvalA, pvalB)) {
> + setVariable(pvarA, pvalB);
> return true;
> }
> return false;
> }
For a language with defined left-to-right evaluation, it is necessary to
dereference <variableA> before computing <expressionB>. This is easy to fix,
by making both the variable's location and its dereferenced value inputs to
the primitive.
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the mozart-users
mailing list