Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Common Lisp, is there a defined maximum length for a symbol's name?

I wasn't able to find this information in the Hyperspec or Common Lisp: The Language (second edition). Implementation-dependent constants like LAMBDA-PARAMETERS-LIMIT and CALL-ARGUMENT-LIMIT, but not something like SYMBOL-NAME-LENGTH-LIMIT or perhaps PRINTABLE-SYMBOL-NAME-MAX-LENGTH.

The standard symbols with the longest names are UPDATE-INSTANCE-FOR-DIFFERENT-CLASS and UPDATE-INSTANCE-FOR-REDEFINED-CLASS, both 35 characters long, so I suppose that 35 could be taken as a maximum. I don't expect to ever name a symbol something longer than that, but it could matter some day.

like image 892
texdr.aft Avatar asked Jul 28 '19 21:07

texdr.aft


1 Answers

In Common Lisp the names of symbols are strings, strings are vectors (one-dimensional arrays) and thus the length of strings is limited by array-dimension-limit.

According to CL HyperSpec http://www.lispworks.com/documentation/HyperSpec/Body/v_ar_dim.htm#array-dimension-limit array-dimension-limit is:

A positive fixnum, the exact magnitude of which is implementation-dependent, but which is not less than 1024.

Practically, SBCL reports

* array-dimension-limit
4611686018427387901

so it's not really a limit.

like image 68
rsm Avatar answered Sep 29 '22 08:09

rsm