Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Pervasives

Spec.Pervasives History

Hide minor edits - Show changes to output

2015-09-25 12:41 by trijezdci -
Changed line 33 from:
[-where @@''`TypeOf(x)''@@ means the identifier of type x and @@''`ElemType''@@ means the identifier of the element type of the indeterminate field of a record of indeterminate type.-] [[<<]]
to:
[-where @@''`TypeOf(x)''@@ means the identifier of type x.-] [[<<]]
2015-09-25 12:39 by trijezdci -
Changed line 31 from:
[[#ProcToDo|@@TODO@@]]@@(str)@@ prints str to console, causes warning in DEBUG mode, or error otherwise [[<<]]
to:
[[#ProcToDo|@@TODO@@]]@@(str)@@ prints @@str@@ to console, causes warning in DEBUG mode, or error otherwise [[<<]]
2015-09-25 12:38 by trijezdci -
Deleted line 26:
[[#ProcToDo|@@TODO@@]] causes compile time warning when in DEBUG mode, otherwise compile time error [[<<]]
Added line 31:
[[#ProcToDo|@@TODO@@]]@@(str)@@ prints str to console, causes warning in DEBUG mode, or error otherwise [[<<]]
2015-09-25 12:35 by trijezdci -
Added line 27:
[[#ProcToDo|@@TODO@@]] causes compile time warning when in DEBUG mode, otherwise compile time error [[<<]]
2015-09-25 12:13 by trijezdci -
Changed lines 45-46 from:
[[#FuncMin|@@FIRST@@]]@@(c)@@ returns first value of collection @@c@@ [[<<]]
[[#FuncMax|@@LAST@@]]@@(c)@@ returns last value of collection @@c@@ [[<<]]
to:
[[#FuncMin|@@FIRST@@]]@@(c)@@ returns first value of ordered collection @@c@@ [[<<]]
[[#FuncMax|@@LAST@@]]@@(c)@@ returns last value of ordered collection @@c@@ [[<<]]
2015-09-25 12:12 by trijezdci -
Changed lines 22-24 from:
[[#ProcInsert|@@INSERT@@]]@@(c, ...)@@ inserts values in set or list, or values at index, or key/value pairs in collection @@c@@ [[<<]]
[[#ProcStore|@@APPEND@@]]@@(c, v1, v2, v3)@@ appends values to list or array collection @@c@@ [[<<]]
[[#ProcStore|@@REMOVE@@]]@@(c, ...)@@ removes elements from set or list, or values in index range, or key/value pairs from collection @@c@@ [[<<]]
to:
[[#ProcInsert|@@INSERT@@]]@@(c, ...)@@ inserts values or accessor/value pairs into collection @@c@@ [[<<]]
[[#ProcStore|@@APPEND@@]]@@(c, v1, v2, v3)@@ appends values to the end of list or array collection @@c@@ [[<<]]
[[#ProcStore|@@REMOVE@@]]@@(c, ...)@@ removes values or key/value pairs from collection @@c@@ [[<<]]
Changed line 42 from:
[[#FuncCount|@@COUNT@@]]@@(c)@@ returns the item count of collection @@c@@ [[<<]]
to:
[[#FuncCount|@@COUNT@@]]@@(c)@@ returns the number of values stored in collection @@c@@ [[<<]]
2015-09-25 12:08 by trijezdci -
Changed lines 47-48 from:
[[#FuncMin|@@MIN@@]]@@(v1, v2, v3 ...)@@ returns smallest value from argument list [[<<]]
[[#FuncMax|@@MAX@@]]@@(v1, v2, v3 ...)@@ returns largest value from argument list [[<<]]
to:
[[#FuncMin|@@MIN@@]]@@(v1, v2, v3 ...)@@ returns smallest value of a list of ordinal or scalar values [[<<]]
[[#FuncMax|@@MAX@@]]@@(v1, v2, v3 ...)@@ returns largest value of a list of ordinal or scalar values [[<<]]
2015-09-25 12:05 by trijezdci -
Changed line 26 from:
[[#ProcSort|@@SORTNEW@@]]@@(t, s, order)@@ creates new target collection @@t@@ with sorted values from source collection @@s@@ [[<<]]
to:
[[#ProcSort|@@SORTNEW@@]]@@(t, s, order)@@ sorts values of source collection @@s@@ into newly allocated target collection @@t@@ [[<<]]
2015-09-25 11:44 by trijezdci -
Changed line 78 from:
The constant @@NIL@@ represents an invalid pointer. It is compatible with any pointer type. Its value is defined as:
to:
The constant @@NIL@@ represents an invalid pointer. It is compatible with '''any''' pointer type. Its value is defined as:
2015-09-25 11:43 by trijezdci -
Changed line 81 from:
[@CONST NIL = 0 :: POINTER TO IMMUTABLE OCTET;@]
to:
[@CONST NIL = 0 :: POINTER TO CONST OCTET;@]
2015-09-25 11:42 by trijezdci -
Changed line 68 from:
to do: add primitive @@SEEK@@
to:
to do: add @@SEEK@@ to pseudo-module for primitives
2015-09-25 11:41 by trijezdci -
Added lines 56-59:
----

!!! Changes

Deleted lines 69-70:

Changed line 72 from:
!!!Detailed Descriptions
to:
!!! Detailed Descriptions
2015-09-25 11:39 by trijezdci -
Changed line 25 from:
[[#ProcSort|@@SORT@@]]@@(t, s, order)@@ sorts values of source collection @@s@@ into target collection@@t@@ [[<<]]
to:
[[#ProcSort|@@SORT@@]]@@(t, s, order)@@ sorts values of source collection @@s@@ into target collection @@t@@ [[<<]]
Changed line 35 from:
[[#FuncAbs|@@ABS@@]]@@(x)@@ returns the absolute (sign removed) value of @@x@@ [[<<]]
to:
[[#FuncAbs|@@ABS@@]]@@(x)@@ returns the absolute value of @@x@@ [[<<]]
Changed line 48 from:
[[#FuncMax|@@MAX@@]]@@(v1, v2, v3 ...)@@ returns largest value from argument list[[<<]]
to:
[[#FuncMax|@@MAX@@]]@@(v1, v2, v3 ...)@@ returns largest value from argument list [[<<]]
2015-09-25 11:37 by trijezdci -
Deleted lines 33-34:

Changed line 56 from:
moved to pseudo-module @@RUNTIME@@:
to:
moved to pseudo-module @@RUNTIME@@: [[<<]]
Changed line 59 from:
to be moved to pseudo-module for primitives
to:
to be moved to pseudo-module for primitives:  [[<<]]
Added line 63:
Changed line 778 from:
>><<
to:
>><<
2015-09-25 11:34 by trijezdci -
Deleted line 21:
[[#ProcStore|@@STORE@@]]@@(c, ...)@@ stores values in set or list, or value at index, or key for value in collection @@c@@  [[<<]]
Changed line 37 from:
[[#FuncAbs|@@ABS@@]]@@(x)@@ returns the absolute value of @@x@@ [[<<]]
to:
[[#FuncAbs|@@ABS@@]]@@(x)@@ returns the absolute (sign removed) value of @@x@@ [[<<]]
Added line 43:
[[#FuncExists|@@EXISTS@@]]@@(c, a, v)@@ returns @@TRUE@@ if value @@v@@ exists for accessor @@a@@ in collection @@c@@ [[<<]]
Changed lines 46-53 from:
[[#FuncTMin|@@TMIN@@]]@@(T)@@ returns smallest legal value of type @@T@@ [[<<]]
[[#FuncTMax|@@TMAX@@]]@@(T)@@ returns largest legal value of type @@T@@ [[<<]]
[[#FuncTLimit|@@TLIMIT@@]]@@(T)@@ returns the capacity of collection type @@T@@ [[<<]]
[[#FuncTSize|@@TSIZE@@]]@@(T)@@ returns allocation size required for type @@T@@ [[<<]]

moved to pseudo-module @@RUNTIME@@:
[[#FuncSize|
@@SIZE@@]]@@(v)@@ returns the allocated size of variable @@v@@ [[<<]]
to:
[[#FuncPtr|@@PTR@@]]@@(v, T)@@ returns typed pointer to variable @@v@@ if its type is compatible with @@T@@ [[<<]]
[[#FuncMin|@@FIRST@@]]@@(c)@@ returns first value of collection @@c@@ [[<<]]
[[#FuncMax|@@LAST@@]]@@(c)@@ returns last value of collection @@c@@ [[<<]]
[[#FuncMin|@@MIN@@]]@@(v1, v2, v3 ...)@@ returns smallest value from argument list [[<<]]
[[#FuncMax|@@MAX@@]]@@(v1, v2, v3 ...)@@ returns largest value from argument list[[<<]]
Changed lines 53-54 from:
[[#MacroMin|@@MIN@@]]@@(c1, c2, c3 ...)@@ inserts smallest constant [[<<]]
[[#MacroMax|@@MAX@@]]@@(c1, c2, c3 ...)@@ inserts largest constant [[<<]]
to:
[[#MacroTMin|@@TMIN@@]]@@(T)@@ replaced by smallest legal value of type @@T@@ [[<<]]
[[#MacroTMax|@@TMAX@@]]@@(T)@@ replaced by largest legal value of type @@T@@ [[<<]]
[[#MacroTLimit|@@TLIMIT@@]]@@(T)@@ replaced by the capacity of collection type @@T@@ [[<<]]
[[#MacroTSize|@@TSIZE@@]]@@(T)@@ replaced by allocation size required for type @@T@@ [[<<]]

moved to pseudo-module @@RUNTIME@@:
[[#FuncSize|@@SIZE@@]]@@(v)@@ returns the allocated size of variable @@v@@ [[<<]]

to be moved to pseudo-module for primitives
[[#ProcStore|@@STORE@@]]@@(c, ...)@@ stores values in set or list, or value at index, or key for value in collection @@c@@  [[<<]]
[[#FuncLength|@@VALUE@@]]@@(c, a)@@ returns value for accessor from collection  @@c@@ [[<<]]
[[#FuncSubset|@@SUBSET@@]]@@(s1, s2)@@ returns @@TRUE@@ if @@s2@@ is a subset of @@s1@@ [[<<]]
to do: add primitive @@SEEK@@

2015-09-25 08:39 by trijezdci -
Added line 11:
Empty collection value: [[#ConstEmpty|@@EMPTY@@]] [[<<]]
Added lines 22-27:
[[#ProcStore|@@STORE@@]]@@(c, ...)@@ stores values in set or list, or value at index, or key for value in collection @@c@@  [[<<]]
[[#ProcInsert|@@INSERT@@]]@@(c, ...)@@ inserts values in set or list, or values at index, or key/value pairs in collection @@c@@ [[<<]]
[[#ProcStore|@@APPEND@@]]@@(c, v1, v2, v3)@@ appends values to list or array collection @@c@@ [[<<]]
[[#ProcStore|@@REMOVE@@]]@@(c, ...)@@ removes elements from set or list, or values in index range, or key/value pairs from collection @@c@@ [[<<]]
[[#ProcSort|@@SORT@@]]@@(t, s, order)@@ sorts values of source collection @@s@@ into target collection@@t@@ [[<<]]
[[#ProcSort|@@SORTNEW@@]]@@(t, s, order)@@ creates new target collection @@t@@ with sorted values from source collection @@s@@ [[<<]]
Added line 29:
[[#ProcRead|@@READNEW@@]]@@(f, x)@@ invokes @@''`TypeOf(x)''.Read(f, x)@@ [[<<]]
2015-09-25 06:42 by trijezdci -
Deleted line 30:
[[#FuncNeg|@@NEG@@]]@@(x)@@ returns the sign reversed value of @@x@@ [[<<]]
Deleted lines 36-37:
[[#FuncSize|@@SIZE@@]]@@(v)@@ returns the allocated size of variable @@v@@ [[<<]]
[[#FuncHigh|@@HIGH@@]]@@(a)@@ returns highest subscript for array @@a@@ [[<<]]
Deleted line 37:
[[#FuncNextV|@@NEXTV@@]]@@(v)@@ returns pointer to next variadic tuple of @@v@@ [[<<]]
Added line 40:
[[#FuncTLimit|@@TLIMIT@@]]@@(T)@@ returns the capacity of collection type @@T@@ [[<<]]
Changed lines 42-44 from:
[[#FuncVal|@@VAL@@]]@@(T, x)@@ equivalent to type conversion expression @@x :: T@@ [[<<]]
to:

moved to pseudo-module @@RUNTIME@@:
[[#FuncSize|
@@SIZE@@]]@@(v)@@ returns the allocated size of variable @@v@@ [[<<]]
2015-09-25 06:28 by trijezdci -
Changed lines 16-17 from:
Unsigned types: [[#TypeOctet|@@OCTET@@]], [[#TypeCardinal|@@CARDINAL@@]], [[#TypeLongcard|@@LONGCARD@@]] [[<<]]
Integer types: [[#TypeInteger|@@INTEGER@@]], [[#TypeLongint|@@LONGINT@@]] [[<<]]
to:
Unsigned whole number types: [[#TypeOctet|@@OCTET@@]], [[#TypeCardinal|@@CARDINAL@@]], [[#TypeLongcard|@@LONGCARD@@]] [[<<]]
Signed whole number types: [[#TypeInteger|@@INTEGER@@]], [[#TypeLongint|@@LONGINT@@]] [[<<]]
2015-09-21 08:02 by trijezdci -
Deleted lines 20-22:
[[#ProcNew|@@NEW@@]]@@(p)@@ invokes @@ALLOCATE(p, TSIZE(''`TypeOf(p^)''))@@ [[<<]]
[[#ProcNew|@@NEW@@]]@@(p, n)@@ invokes @@ALLOCATE(p, TSIZE(''`TypeOf(p^)'') + n * TSIZE(''`ElemType''))@@ [[<<]]
[[#ProcDispose|@@DISPOSE@@]]@@(p)@@ invokes @@DEALLOCATE(p, SIZE(p^))@@ [[<<]]
Added lines 27-28:

Deleted lines 200-261:
[[#ProcNew]]
!!!!!Procedure @@NEW@@

Procedure @@NEW@@ is used to dynamically allocate storage at runtime. The procedure is defined as:

[@<*INLINE*> PROCEDURE NEW ( VAR p : <PointerType>; (* OPTIONAL *) n : <unsignedTypes> );
  (* calculates the required storage size for the base type of p, allocates a block of
    storage of the determined size and passes its address back in p, if p points to
    an indeterminate type, then the determinant value must be passed in n *)@]

!!!!!!Static Semantics:

A call of @@NEW@@ must have one or two actual parameters. The first parameter may be a variable of any pointer type. If the first parameter is a pointer to an indeterminate type, then a second parameter must be passed in. The second parameter may be a value of type @@OCTET@@, @@CARDINAL@@ or @@LONGCARD@@. A library procedure named @@ALLOCATE@@ must be visible in the lexical scope where @@NEW@@ is called. The library procedure must conform to the following signature:

[@PROCEDURE ALLOCATE ( VAR p : ADDRESS; size : LONGCARD );@]

!!!!!!Dynamic Semantics:

Procedure @@NEW@@ allocates storage at runtime and passes a pointer to the allocated storage back in its first parameter. It calls function @@TSIZE@@ to calculate the required storage size and it calls library procedure @@ALLOCATE@@ to allocate storage. The semantics are defined as:

>>background-color:#f4f4f4 padding:0.5em border:'thin solid gray' whitespace:pre<<
@@'''macro''' NEW ( ''byref'' p : pointer; '''optional''' n : anyCardinalType )@@
  @@targetType := baseTypeOf(p)@@
  @@baseSize := '''evaluate''' TSIZE(targetType)@@
  @@'''if''' isDeterminateType(targetType) '''then'''@@
    @@'''insert''' ALLOCATE(p, baseSize)@@
  @@'''elsif''' isIndeterminateType(targetType) '''and''' isPresent(n) '''then'''@@
    @@indeterminateComponent := symTabLookup(targetType, indeterminateField, name)@@
    @@componentType :=  baseTypeOf(p^.indeterminateComponent)@@
    @@'''insert''' ALLOCATE(p, baseSize + n * TSIZE(componentType))@@
    @@determinant := symTabLookup(targetType, determinantField, name)@@
    @@'''insert''' p^.determinant := n@@
  @@'''else'''@@
    @@raiseCompileTimeError@@
  @@'''endif'''@@
@@'''endm'''@@
>><<


[[#ProcDispose]]
!!!!!Procedure @@DISPOSE@@

Procedure @@DISPOSE@@ is used to release dynamically allocated storage that was reserved by a call to procedure @@NEW@@. The procedure is defined as:

[@<*INLINE*> PROCEDURE DISPOSE ( VAR p : <AnyPointerType> );
  (* release the storage previously allocated by a call to NEW and pointed to by p *)@]

!!!!!!Static Semantics:

A call of @@DISPOSE@@ must have one actual parameter. The parameter may be a variable of any pointer type. A library procedure named @@DEALLOCATE@@ must be visible in the lexical scope where @@DISPOSE@@ is called. The library procedure must conform to the following signature:

[@PROCEDURE DEALLOCATE ( VAR p : ADDRESS; size : LONGCARD );@]

!!!!!!Dynamic Semantics:

Procedure @@DISPOSE@@ first calls function @@SIZE@@ to determine the allocation size of the storage block pointed to by its first argument and then it deallocates the storage block by calling library procedure @@DEALLOCATE@@ passing the pointer and allocated size. The semantics are defined as:

>>background-color:#f4f4f4 padding:0.5em border:'thin solid gray' whitespace:pre<<
@@'''macro''' DISPOSE ( ''byref'' p : pointer )@@
  @@'''insert''' DEALLOCATE(p, SIZE (p^))@@
@@'''endm'''@@
>><<
2015-09-21 07:54 by trijezdci -
Changed line 1 from:
Predefined identifiers are language defined identifiers that are visible in any lexical scope without import. They fall into five categories:
to:
Predefined identifiers (formerly called pervasives) are language defined identifiers that are visible in any lexical scope without import. They fall into five categories:
2015-09-21 07:54 by trijezdci -
Changed lines 1-6 from:
Pervasives are predefined identifiers that are visible in any lexical scope without import. Unlike reserved words, pervasives may be redefined. Pervasives fall into five categories: constants, types, procedures, functions and compile-time macros:
to:
Predefined identifiers are language defined identifiers that are visible in any lexical scope without import. They fall into five categories:
* constants
* types
* procedures
* functions
* compile-time macros