Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:32:16+00:00 2026-05-16T01:32:16+00:00

In Common LISP I can do: (setf a1 ‘a) (setf 1a ‘b) In clojure

  • 0

In Common LISP I can do:

(setf a1 'a)
(setf 1a 'b)

In clojure I can do the first (ignoring the fact that setf and def work differently)

(def a1 'a)

but with the second I get an error

(def 1a 'b)

java.lang.NumberFormatException: Invalid number: 1a

Did Clojure just inherit this limitation from Java, or is it deliberate? (ie you can’t have a class name, variable or method name with Java with this style – so I assume it has just carried across.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:32:17+00:00Added an answer on May 16, 2026 at 1:32 am

    Clojure’s symbol literals are documented to need to start with a non-numeric character. This has nothing to do with Java identifier or numeric literal syntax — a Clojure symbol literal is whatever clojure.lang.LispReader‘s read method reads in as a symbol and there’s a number of characters permitted within Clojure symbol literals which are not admissible in Java identifiers (e.g. -, >…; there’s also a scheme for translating those into character sequences such as _GT_ for > for interop purposes). The direct cause for the error is that clojure.lang.LispReader/read dispatches to readNumber immediately upon seeing a digit and there’s no way to “back out” of that.


    A tangential discussion for the sake of completeness.

    Note that if you construct a symbol by hand, you can use it to name a Var:

    ;; Clojure's intern serves a different purpose to CL's intern, see (doc intern)
    user> (intern *ns* (symbol "1+") inc)
    #'user/1+
    user> ((ns-resolve *ns* (symbol "1+")) 1)
    2
    

    You can even do funky stuff like

    user> (eval `(defrecord ~(symbol "1foo") []))
    user.1foo
    user> user.1foo
    user.1foo
    user> (user.1foo.)
    #:user.1foo{}
    

    …which is of course totally crazy, though perhaps not as much as

    user> (in-ns (symbol "1foo"))
    #<Namespace 1foo>
    1foo> (clojure.core/refer-clojure)
    nil
    1foo> (defrecord Foo [])
    1foo.Foo
    1foo> (in-ns 'user)
    #<Namespace user>
    user> (1foo.Foo.)
    ; Evaluation aborted.   ;; can't do that
    user> (eval `(new ~(symbol "1foo.Foo")))
    #:1foo.Foo{}
    

    I suppose that if one insisted on doing this sort of things, one would ultimately bump into JVM limitations. There is of course no good purpose to doing so… Anyway, back to the original question, the error caused by 1+ has to do with symbol literal syntax, which is Java-friendly only to the degree that a reasonable “translation” exists. Clojure objects which have names don’t care much about those names being well-formed or otherwise, although using funky names is unwieldy and definitely not supported.

    (And user.1foo from the example above is actually a Java class — I’m a bit surprised to see that this one has actually worked, though on the other hand I seem to recall the JVM’s internal limitations on names are supposed to be less strict than those of Java.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I installed ltk to Steel Bank Common Lisp with asdf-install, but I can't even
I find it handy in Python or Common Lisp that you can list a
Can classes have multiple constructors and/or copy constructors in common-lisp? That is - in
can I use common lisp and Clojure from within emacs at the same time?
Does clojure have a powerful 'loop' like common lisp. for example: get two elements
I'd like to be able to define lambdas using common Lisp syntax, in Clojure.
I know I can do the following in Common Lisp: CL-USER> (let ((my-list nil))
In common lisp I can do this: (mapcar #'cons '(1 2 3) '(a b
Can anyone tell me about using (Steel Bank) Common Lisp for writing GUIs via
In Common Lisp I can conditionally exclude or include code for different implementations like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.