(* * This file is an attempt to represent an rsl runtime value in rsl. We note * that we seem not to need an explicit type tag, since rsl provides this for * us automatically. This seems kinda sweet, if it pans out. *) object Value = i: integer or r: real or b: boolean or s: string or l: ListValue or t: TupleValue or u: UnionValue or o: OpValue; object ListValue = Value*; object TupleValue = TupleFieldValue*; object UnionValue = t:Tag and v:TupleValue; object OpValue = op(Value)->(Value); object TupleFieldValue = n:FieldName and v:Value; object FieldName = string; object Tag = string; operation Dot(v:Value,fn:FieldName)->(Value) = if (v?.t) then FieldSelect(v.t, fn) else if (v?.u) then FieldSelect(v.u.v, fn) else nil description: (* This is an overloading of '.' for Value's. It allows almost syntactically nice record refs of the form x."y" for some TupleValue x with field named "y". WARNING: Overloading '.' may not be allowable, since it built-in def seems to be a fexper. THIS REQUIES SOME MORE THOUGHT. *); end Dot; function FieldSelect(tv:TupleValue, fn:FieldName) -> (Value) = if tv = nil then nil else if tv[1].n = fn then tv[1].v else FieldSelect(tv[2:#tv], fn);