diff options
Diffstat (limited to 'src/algebra/boolean.spad.pamphlet')
-rw-r--r-- | src/algebra/boolean.spad.pamphlet | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/algebra/boolean.spad.pamphlet b/src/algebra/boolean.spad.pamphlet index 7562b3b5..4e307819 100644 --- a/src/algebra/boolean.spad.pamphlet +++ b/src/algebra/boolean.spad.pamphlet @@ -392,42 +392,35 @@ PropositionalFormulaFunctions2(S,T): Public == Private where )abbrev domain REF Reference ++ Author: Stephen M. Watt ++ Date Created: -++ Date Last Changed: May 27, 2009 -++ Basic Operations: deref, elt, ref, setelt, setref, = +++ Date Last Changed: October 11, 2011 +++ Basic Operations: deref, ref, setref, = ++ Related Constructors: ++ Keywords: reference ++ Description: \spadtype{Reference} is for making a changeable instance ++ of something. -Reference(S:Type): Type with +Reference(S:Type): SetCategory with ref : S -> % - ++ ref(n) creates a pointer (reference) to the object n. - elt : % -> S - ++ elt(n) returns the object n. - setelt: (%, S) -> S - ++ setelt(n,m) changes the value of the object n to m. - -- alternates for when bugs don't allow the above + ++ \spad{ref(s)} creates a reference to the object \spad{s}. deref : % -> S - ++ deref(n) is equivalent to \spad{elt(n)}. + ++ \spad{deref(r)} returns the object referenced by \spad{r} setref: (%, S) -> S - ++ setref(n,m) same as \spad{setelt(n,m)}. - = : (%, %) -> Boolean - ++ a=b tests if \spad{a} and b are equal. - if S has SetCategory then SetCategory - + ++ setref(r,s) reset the reference \spad{r} to refer to \spad{s} + = : (%, %) -> Boolean + ++ \spad{a=b} tests if \spad{a} and \spad{b} are equal. == add - Rep := Record(value: S) - - p = q == %peq(p,q)$Foreign(Builtin) - ref v == [v] - elt p == p.value - setelt(p, v) == p.value := v - deref p == p.value - setref(p, v) == p.value := v - - if S has SetCategory then - coerce p == - prefix('ref::OutputForm, [p.value::OutputForm]) + Rep == Record(value: S) + import %peq: (%,%) -> Boolean from Foreign Builtin + + p = q == %peq(p,q) + ref v == per [v] + deref p == rep(p).value + setref(p, v) == rep(p).value := v + coerce p == + obj := + S has CoercibleTo OutputForm => rep(p).value::OutputForm + '?::OutputForm + prefix('ref::OutputForm, [obj]) @ |