Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
STANDART PASCAL ISO 1990.doc
Скачиваний:
5
Добавлен:
17.11.2019
Размер:
251.66 Кб
Скачать

6.6.5.3 Dynamic allocation procedures

new(p)

shall create a new variable that is totally-undefined, shall create a new identifying-value of the pointer-type associated with p, that identifies the new variable, and shall attribute this identifying-value to the variable denoted by the variable-access p. The created variable shall possess the type that is the domain-type of the pointer-type possessed by p.

new(p,c1 ,...,cn)

shall create a new variable that is totally-undefined, shall create a new identifying-value of the pointer-type associated with p, that identifies the new variable, and shall attribute this identifying-value to the variable denoted by the variable-access p. The created variable shall possess the record-type that is the domain-type of the pointer-type possessed by p and shall have nested variants that correspond to the case-constants c1,...,cn. The case-constants shall be listed in order of increasing nesting of the variant-parts. Any variant

not specified shall be at a deeper level of nesting than that specified by cn.

It shall be an error if a variant of a variant-part within the new variable is active and a different variant of the variant-part is one of the specified variants.

dispose(q)

shall remove the identifying-value denoted by the expression q from the pointer-type of q. It shall be an error if the identifying-value had been created using the form new(p,c1,...,cn).

dispose(q,k1,...,km)

shall remove the identifying-value denoted by the expression q from the pointer-type of q. The case-constants k1,...,km shall be listed in order of increasing nesting of the variant-parts. It shall be an error unless the variable had been created using the form new(p,c1,...,cn) and m is equal to n. It shall be an error if the variants in the variable identified by the pointer value of q are different from those specified by the values denoted by the case-constants k1,...,km.

NOTE --- The removal of an identifying-value from the pointer-type to which it belongs renders the identified-variable inaccessible (see 6.5.4) and makes undefined all variables and functions that have that value attributed (see 6.6.3.2 and 6.8.2.2).

It shall be an error if q has a nil-value or is undefined.

It shall be an error if a variable created using the second form of new is accessed by the identified-variable of the variable-access of a factor, of an assignment-statement, or of an actual-parameter.

6.6.5.4 Transfer procedures

In the statement pack(a,i,z) and in the statement unpack(z,a,i) the following shall hold: a and z shall be variable-accesses; a shall possess an array-type not designated packed; z shall possess an array-type designated packed; the component-types of the types of a and z shall be the same; and the value of the expression i shall be assignment-compatible with the index-type of the type of a.

Let j and k denote auxiliary variables that the program does not otherwise contain and that have the type that is the index-type of the type of z and a, respectively. Let u and v denote the smallest and largest values of the index-type of the type of z. Each of the statements pack(a,i,z) and unpack(z,a,i) shall establish references to the variables denoted by a and z for the remaining execution of the statements; let aa and zz, respectively, denote the referenced variables within the following sentence. Then the statement pack(a,i,z) shall be equivalent to

begin

k := i;

for j := u to v do

begin

zz[j] := aa[k];

if j <> v then k := succ(k)

end

end

and the statement unpack(z,a,i) shall be equivalent to

begin

k := i;

for j := u to v do

begin

aa[k] := zz[j];

if j <> v then k := succ(k)

end

end

NOTE --- Errors will arise if the references cannot be established, if one or more of the values attributed to j is not assignment-compatible with the index-type of the type of a, or if an evaluated array component is undefined.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]