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

1

6

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.

Wellheeled answered 28/7, 2019 at 21:51 Comment(2)
https://mcmap.net/q/340290/-maximum-method-name-length ??Openhearted
@Openhearted thanks. so the standard minimum is 1024 characters; if you'd like to make that into an answer, go ahead.Wellheeled
O
12

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.

Openhearted answered 29/7, 2019 at 1:57 Comment(2)
Side note: CLtL2 is not really spec. It's a language description of a version of Common Lisp before it was specified as ANSI Common Lisp. Thus there are differences to the actual ANSI CL spec. A HTML rendering of something which has basically the same contents as the spec is the HyperSpec: lispworks.com/documentation/HyperSpec/Front/Contents.htmFacet
@RainerJoswig Oh, I didn't knew that, thanks! I changed CLtL2 part to HyperSpec.Openhearted

© 2022 - 2024 — McMap. All rights reserved.