File: object.doc

package info (click to toggle)
symmetrica 2.0+ds-6
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 9,456 kB
  • sloc: ansic: 97,289; makefile: 170; sh: 70
file content (135 lines) | stat: -rw-r--r-- 3,397 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
COMMENT:
OBJECT

The object is the only datatype of SYMMETRICA. It is a structure
with two components. The first one is the kind, this is an
information, which allows the system to decide how to handle
the object. (e.g. there are different subroutines to add
INTEGER objects or  POLYNOM objects) Using the kind-information
the global routine add can switch to the correct subroutine.
This information is of the datatype
	OBJECTKIND
which is defined in the file "def.h". There are several known
kinds of objects. An incomplete list follows
	EMPTY
	INTEGER
	VECTOR
	PARTITION
	PERMUTATION
	LIST
	POLYNOM
	SCHUR
	MATRIX
	.
	.
	.
The complete list is in the file "def.h", which defines these names.
They are covered in the following chapters of this documentation.
The header of the chapters are the names of the different values
of the kind. The first step in a program of SYMMETRICA is the
generation of an object. This object is always an empty object.
This is done in the following program

#include "def.h"
#include "macro.h"
main()
{
OP object;
anfang();
object = callocobject();               /* generation of an object */
freeall(object);                       /* deletion of an object */
ende();
}

Using the routine callocobject() you generate an empty object. This 
object must have been declared using the type OP, which is also
defined in "def.h". After all you have to delete the object, this is 
done using the standard routine freeall(), which works for all
objects, not only with empty objects. If you print an empty object
you will get a "#", which is the symbol for the empty object. If you 
change the above code into
.
.
.
object = callocobject();               /* generation of an object */
println(object);
freeall(object);                       /* deletion of an object */
.
.
.
you get the following line

#

To get the information about the kind of an object, you have the 
routine s_o_k(), look at the following part of the pseudostandard
routine print:
.
.
INT print(a) OP a;
.
switch(s_o_k(a)) {
	case INTEGER: return(print_integer(a));
	.
	}
.
.
the complete description:

NAME: 
         s_o_k
SYNOPSIS:    
	  OBJECTKIND s_o_k(OP object)
MACRO:
    S_O_K
DESCRIPTION:
   As OP is a pointer, there is first a check,
	whether it is the NULL pointer, then it
	returns the kind of the object.
  The macro S_O_K does the smae but without a check.
RETURN: 
       The returnvalue is the kind, or in the case of
        an error the value (OBJECTKIND)ERROR. You have to cast
	because in the normal case ERROR is of type INT.

COMMENT:
To change the kind of an object, you have the routine c_o_k()

NAME:  
	        c_o_k
SYNOPSIS:
	INT c_o_k(OP object, OBJECTKIND kind)
MACRO:
  C_O_K
DESCRIPTION:
	  As OP is a pointer, there is first a check,
	whether it is the NULL pointer, then the
	kind of the object is changed to kind.
	The macro C_O_K does the same but without a check.
RETURN:
	        The returnvalue is OK, or ERROR if an error occured

COMMENT:
The second part of an object, are the datas themself. The type is 
defined in "def.h" as OBJECTSELF

NAME:
	s_o_s
SYNOPSIS:
	OBJECTSELF s_o_s(OP a)
MACRO:
	S_O_S
DESCRIPTION:
	acess the self part of an object. This is a union 
	of different datatypes according to the kind part
	of the object

NAME:
	c_o_s
SYNOPSIS:
	INT c_o_s(OP a, OBJECTSELF self)
MACRO:
	C_O_S
DESCRIPTION:
	changes the self part of an object a.