2.8 Symbols

There are no implementation-specific limits on the size or content of symbol names. It is however not allowed to write on the strings which have been passed to #'make-symbol or returned from #'symbol-name.

2.8.1 C Reference

Function: cl_object ecl_make_keyword (char *name);

Find a lisp keyword

Description

Many Lisp functions take keyword arguments. When invoking a function with keyword arguments we need keywords, which are a kind of symbols that live in the keyword package. This function does the task of finding or creating those keywords from C strings.

  • It is usually safe to store the resulting pointer, because keywords are always referenced by their package and will not be garbage collected (unless of course, you decide to delete it).
  • Remember that the case of the string is significant. ecl_make_keyword("TO") with return :TO, while ecl_make_keyword("to") returns a completely different keyword, :|to|. In short, you usually want to use uppercase.

Example

The following example converts a section of a string to uppercase characters:

cl_object start = ecl_make_keyword("START");
cl_object end = ecl_make_keyword("END");
...
sup = cl_string_upcase(4, s, start, ecl_make_fixnum(2),
                       end, ecl_make_fixnum(6));
Function: cl_object ecl_make_symbol (const char *name, const char *package_name);

Find a lisp symbol

Description

This function finds or create a symbol in the given package. First of all, it tries to find the package named by package_name. If it does not exist, an error is signaled. Then, a symbol with the supplied name is created and interned in the given package.

2.8.1.1 ANSI Dictionary

Common Lisp and C equivalence

Lisp symbolC function
boundpcl_object cl_boundp(cl_object symbolp)
copy-symbolcl_object cl_copy_symbol(cl_narg narg, cl_object symbol, ...)
getcl_object cl_get(cl_narg narg, cl_object sym, cl_object indicator, ...)
gensymcl_object cl_gensym(cl_narg narg, ...)
gentempcl_object cl_gentemp(cl_narg narg, ...)
keywordpcl_object cl_keywordp(cl_object object)
make-symbolcl_object cl_make_symbol(cl_object name)
makunboundcl_object cl_makunbound(cl_object makunbound)
rempropcl_object cl_remprop(cl_object symbol, cl_object indicator)
setcl_object cl_set(cl_object symbol, cl_object value)
symbolpcl_object cl_symbolp(cl_object object)
symbol-functioncl_object cl_symbol_function(cl_object symbol)
(setf symbol-function)cl_object si_fset(cl_narg narg, cl_object function_name, cl_object definition, ...)
symbol-namecl_object cl_symbol_name(cl_object symbol)
symbol-packagecl_object cl_symbol_package(cl_object symbol)
symbol-plistcl_object cl_symbol_plist(cl_object symbol)
(setf symbol-plist)cl_object si_set_symbol_plist(cl_object symbol, cl_object plist)
symbol-valuecl_object cl_symbol_value(cl_object symbol)