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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
\function{__class_id}
\synopsis{Return the class-id of a specified type}
\usage{Int_Type __class_id (DataType_Type type))}
\description
This function returns the internal class-id of a specified data type.
\seealso{typeof, _typeof, __class_type}
\done
\function{__class_type}
\synopsis{Return the class-type of a specified type}
\usage{Int_Type __class_type (DataType_Type type))}
\description
Internally \slang objects are classified according to four types:
scalar, vector, pointer, and memory managed types. For example, an
integer is implemented as a scalar, a complex number as a vector,
and a string is represented as a pointer. The \var{__class_type}
function returns an integer representing the class-type associated
with the specified data type. Specifically, it returns:
#v+
0 memory-managed
1 scalar
2 vector
3 pointer
#v-
\seealso{typeof, _typeof, __class_id}
\done
\function{__eqs}
\synopsis{Test for equality between two objects}
\usage{Int_Type __eqs (a, b)}
\description
This function tests its two arguments for equalit and returns \1
if they are equal, and \0 otherwise. To be equal, the data type of
the arguments must match and the values of the objects must
reference the same underlying object.
\example
__eqs (1, 1) ===> 1
__eqs (1, 1.0) ===> 0
__eqs ("a", 1) ===> 0
__eqs ([1,2], [1,2]) ===> 0
\seealso{typeof, __get_reference}
\notes
This function should be thought of as a test for "sameness".
\done
\function{__get_reference}
\synopsis{Get a reference to a global object}
\usage{Ref_Type __get_reference (String_Type nm)}
\description
This function returns a reference to a global variable or function
whose name is specified by \var{nm}. If no such object exists, it
returns \var{NULL}, otherwise it returns a reference.
\example
For example, consider the function:
#v+
define runhooks (hook)
{
variable f;
f = __get_reference (hook);
if (f != NULL)
@f ();
}
#v-
This function could be called from another \slang function to
allow customization of that function, e.g., if the function
represents a mode, the hook could be called to setup keybindings
for the mode.
\seealso{is_defined, typeof, eval, autoload, __is_initialized, __uninitialize}
\done
\function{__uninitialize}
\synopsis{Uninitialize a variable}
\usage{__uninitialize (Ref_Type x)}
\description
The \var{__uninitialize} function may be used to uninitialize the
variable referenced by the parameter \var{x}.
\example
The following two lines are equivalent:
#v+
() = __tmp(z);
__uninitialize (&z);
#v-
\seealso{__tmp, __is_initialized}
\done
\variable{_auto_declare}
\synopsis{Set automatic variable declaration mode}
\usage{Integer_Type _auto_declare}
\description
The \var{_auto_declare} may be used to have all undefined variables
implicitely declared as \var{static}. If set to zero, any variable
must be declared witha \var{variable} declaration before it can be
used. If set to one, then any undeclared variabled will be declared
as a \var{static} global variable.
The \var{_auto_declare} variable is local to each compilation unit and
setting its value in one unit has no effect upon its value in other
units. The value of this variable has no effect upon the variables
in a function.
\example
The following code will not compile if \var{X} not been
declared:
#v+
X = 1;
#v-
However,
#v+
_auto_declare = 1; % declare variables as static.
X = 1;
#v-
is equivalent to
#v+
static variable X = 1;
#v-
\notes
This variable should be used sparingly and is intended primarily for
interactive applications where one types \slang commands at a prompt.
\done
\function{current_namespace}
\synopsis{Get the name of the current namespace}
\usage{String_Type current_namespace ()}
\description
The \var{current_namespace} function returns the name of the
current namespace. If the current namespace is anonymous, that is,
has not been given a name via the \var{implements} function, the
empty string \exmp{""} will be returned.
\seealso{implements, use_namespace, import}
\done
\function{getenv}
\synopsis{Get the value of an environment variable}
\usage{String_Type getenv(String_Type var)}
\description
The \var{getenv} function returns a string that represents the
value of an environment variable \var{var}. It will return
\var{NULL} if there is no environment variable whose name is given
by \var{var}.
\example
#v+
if (NULL != getenv ("USE_COLOR"))
{
set_color ("normal", "white", "blue");
set_color ("status", "black", "gray");
USE_ANSI_COLORS = 1;
}
#v-
\seealso{putenv, strlen, is_defined}
\done
\function{implements}
\synopsis{Name a private namespace}
\usage{implements (String_Type name);}
\description
The \var{implements} function may be used to name the private
namespace associated with the current compilation unit. Doing so
will enable access to the members of the namespace from outside the
unit. The name of the global namespace is \exmp{Global}.
\example
Suppose that some file \exmp{t.sl} contains:
#v+
implements ("Ts_Private");
static define message (x)
{
Global->vmessage ("Ts_Private message: %s", x);
}
message ("hello");
#v-
will produce \exmp{"Ts_Private message: hello"}. This \var{message}
function may be accessed from outside via:
#v+
Ts_Private->message ("hi");
#v-
\notes
Since \var{message} is an intrinsic function, it is global and may
not be redefined in the global namespace.
\seealso{use_namespace, current_namespace, import}
\done
\function{putenv}
\synopsis{Add or change an environment variable}
\usage{putenv (String_Type s)}
\description
This functions adds string \var{s} to the environment. Typically,
\var{s} should of the form \var{"name=value"}. The function
signals a \slang error upon failure.
\notes
This function is not available on all systems.
\seealso{getenv, sprintf}
\done
\function{use_namespace}
\synopsis{Change to another namespace}
\usage{use_namespace (String_Type name)}
\description
The \var{use_namespace} function changes the current namespace to
the one specified by the parameter. If the specified namespace
does not exist, an error will be generated.
\seealso{implements, current_namespace, import}
\done
|