25
25
cl_make_symbol(cl_object str)
27
assert_type_string(str);
28
str = si_copy_to_simple_base_string(str);
29
@(return make_symbol(str))
33
make_symbol(cl_object st)
29
/* INV: In several places it is assumed that we copy the string! */
30
switch (type_of(str)) {
33
if (!ecl_fits_in_base_string(str)) {
34
str = cl_copy_seq(str);
36
str = si_copy_to_simple_base_string(str);
41
str = si_copy_to_simple_base_string(str);
44
str = ecl_type_error(@'make-symbol',"name",str,@'string');
37
47
x = cl_alloc_object(t_symbol);
38
/* FIXME! Should we copy? */
39
x->symbol.name = si_copy_to_simple_base_string(st);
40
49
x->symbol.dynamic = 0;
41
50
ECL_SET(x,OBJNULL);
45
54
x->symbol.stype = stp_ordinary;
46
55
x->symbol.mflag = FALSE;
47
56
x->symbol.isform = FALSE;
52
Make_keyword(s) makes a keyword from C string s.
61
ecl_make_keyword(s) makes a keyword from C string s.
55
make_keyword(const char *s)
64
ecl_make_keyword(const char *s)
57
cl_object x = _intern(s, cl_core.keyword_package);
58
/* cl_export(x, keyword_package); this is implicit in intern() */
66
cl_object x = _ecl_intern(s, cl_core.keyword_package);
67
/* cl_export(x, keyword_package); this is implicit in ecl_intern() */
63
symbol_value(cl_object s)
72
ecl_symbol_value(cl_object s)
65
74
/* FIXME: Should we check symbol type? */
66
75
cl_object value = SYM_VAL(s);
174
keywordp(cl_object s)
183
ecl_keywordp(cl_object s)
176
185
return (SYMBOLP(s) && s->symbol.hpack == cl_core.keyword_package);
179
188
@(defun get (sym indicator &optional deflt)
181
assert_type_symbol(sym);
190
sym = ecl_check_cl_type(@'get', sym, t_symbol);
182
191
@(return ecl_getf(sym->symbol.plist, indicator, deflt))
186
195
cl_remprop(cl_object sym, cl_object prop)
188
assert_type_symbol(sym);
197
sym = ecl_check_cl_type(@'remprop', sym, t_symbol);
189
198
@(return (remf(&sym->symbol.plist, prop)? Ct: Cnil))
193
202
cl_symbol_plist(cl_object sym)
195
assert_type_symbol(sym);
204
sym = ecl_check_cl_type(@'symbol-plist', sym, t_symbol);
196
205
@(return sym->symbol.plist)
226
235
cl_symbol_name(cl_object x)
228
assert_type_symbol(x);
237
x = ecl_check_cl_type(@'symbol-name', x, t_symbol);
229
238
@(return x->symbol.name)
232
241
@(defun copy_symbol (sym &optional cp &aux x)
234
assert_type_symbol(sym);
235
x = make_symbol(sym->symbol.name);
243
x = ecl_check_cl_type(@'copy-symbol', x, t_symbol);
244
x = cl_make_symbol(sym->symbol.name);
238
247
x->symbol.stype = sym->symbol.stype;
250
259
cl_object counter, output;
254
if (t == t_base_string) {
263
if (ecl_stringp(prefix)) {
255
264
counter = SYM_VAL(@'*gensym-counter*');
257
} else if (t == t_fixnum || t == t_bignum) {
266
} else if ((t = type_of(prefix)) == t_fixnum || t == t_bignum) {
258
267
counter = prefix;
259
268
prefix = cl_core.gensym_prefix;
262
FEwrong_type_argument(cl_list(3, @'or', @'string', @'integer'),
271
prefix = ecl_type_error(@'gensym',"prefix",prefix,
272
cl_list(3, @'or', @'string', @'integer'));
265
275
output = ecl_make_string_output_stream(64);
266
276
bds_bind(@'*print-base*', MAKE_FIXNUM(10));
267
277
bds_bind(@'*print-radix*', Cnil);
268
princ(prefix, output);
269
princ(counter, output);
278
ecl_princ(prefix, output);
279
ecl_princ(counter, output);
271
output = make_symbol(cl_get_output_stream_string(output));
281
output = cl_make_symbol(cl_get_output_stream_string(output));
273
ECL_SETQ(@'*gensym-counter*',one_plus(counter));
283
ECL_SETQ(@'*gensym-counter*',ecl_one_plus(counter));
277
@(defun gentemp (&optional (prefix cl_core.gentemp_prefix) (pack current_package()))
287
@(defun gentemp (&optional (prefix cl_core.gentemp_prefix) (pack ecl_current_package()))
278
288
cl_object output, s;
281
assert_type_base_string(prefix);
291
prefix = ecl_check_type_string(@'gentemp', prefix);
282
292
pack = si_coerce_to_package(pack);
284
294
output = ecl_make_string_output_stream(64);
285
295
bds_bind(@'*print-base*', MAKE_FIXNUM(10));
286
296
bds_bind(@'*print-radix*', Cnil);
287
princ(prefix, output);
288
princ(cl_core.gentemp_counter, output);
297
ecl_princ(prefix, output);
298
ecl_princ(cl_core.gentemp_counter, output);
290
cl_core.gentemp_counter = one_plus(cl_core.gentemp_counter);
291
s = intern(cl_get_output_stream_string(output), pack, &intern_flag);
300
cl_core.gentemp_counter = ecl_one_plus(cl_core.gentemp_counter);
301
s = ecl_intern(cl_get_output_stream_string(output), pack, &intern_flag);
292
302
if (intern_flag != 0)
298
308
cl_symbol_package(cl_object sym)
300
assert_type_symbol(sym);
310
sym = ecl_check_cl_type(@'symbol-package', sym, t_symbol);
301
311
@(return sym->symbol.hpack)
305
315
cl_keywordp(cl_object sym)
307
@(return ((SYMBOLP(sym) && keywordp(sym))? Ct: Cnil))
317
@(return ((SYMBOLP(sym) && ecl_keywordp(sym))? Ct: Cnil))
356
366
@si::*make_special(cl_object sym)
358
assert_type_symbol(sym);
368
sym = ecl_check_cl_type(@'defvar', sym, t_symbol);
359
369
if ((enum ecl_stype)sym->symbol.stype == stp_constant)
360
370
FEerror("~S is a constant.", 1, sym);
361
371
sym->symbol.stype = (short)stp_special;