// //------------------ DOK FILE -------------------------------------------------- +Header referenceLib =pkg bios =title Reference =short a simple parametric structure =desc A reference is like a memory cell which contains a value. It is possible to modify this value. It is implemented as a simple parametric structure with a single field. // // //------------------ PROTO ----------------------------------------------------- Ref +Proto Ref =type Ref{a1} =mode structure =pkg bios =impl mcy =link =desc The parametric type of the references. // // //------------------ PROTO ----------------------------------------------------- refCreate +Proto refCreate =type fun a1 -> Ref{a1} =mode function =pkg bios =impl mcy =link =desc This function returns a new reference with value as initial content. > refCreate (123) >-> Ref(Int): > _valRef: > Int: 123 (0x7B) This example shows that the Ref structure has a single field, called _valRef. // +arg value =type a1 =desc A value of any type // +arg result =type Ref{a1} =desc A reference of the same type // // //------------------ PROTO ----------------------------------------------------- refGet +Proto refGet =type fun Ref{a1} -> a1 =mode function =pkg bios =impl mcy =link =desc This function returns the content of the reference. // +arg ref =type Ref{a1} =desc A reference of any type // +arg result =type a1 =desc A value of this type // // //------------------ PROTO ----------------------------------------------------- refSet +Proto refSet =type fun Ref{a1} a1 -> a1 =mode function =pkg bios =impl mcy =link =desc This function updates the content of the reference. // +arg ref =type Ref{a1} =desc A reference of any type // +arg val =type a1 =desc A value of this type // +arg result =type a1 =desc The same value