In elisp, symbols serve as fundamental data structures that are more foundational compared to strings. This distinction often caused confusion for me until my encounter with the read function.

 ~ $ (type-of (read))
 symbol

The fact that the read function yields symbols instead of strings from user-input was a delightful revelation. This discovery convinces me that the fundamental nature of symbols in elisp when compared to strings.

You are viewing a single thread.
View all comments View context
1 point

Interesting. It’s intelligent capability to discern and identify numbers, strings, and symbols. What I tried is to feed to minibuffer word string.

permalink
report
parent
reply
1 point

What I tried is to feed to minibuffer word string.

So you have called:

M-: (type-of (read)) RET string RET?

You have just created a temporary symbol named “string”. You can try this to see for yourself:

M-: (symbol-name (type-of (read))) RET

If you want a string object out of “string”, you will have to quote it in the minibuffer too:

M-: (type-of (read)) RET "string" RET?

I think you should have not downvoted /u/lispm below (or whomever it was); he has given a few very good questions to get you going on in exploring those things on your own.

permalink
report
parent
reply
1 point
(type-of (read "foo"))
symbol

(type-of (read "\"foo\""))
string

(type-of (read "42"))
integer

(type-of (read "[42]"))
vector

(type-of (read "(42)"))
cons

Etc, etc…

The lisp reader reads text and it produces lisp objects of various types (which might later be evaluated as code).

permalink
report
parent
reply

Emacs

!emacs@communick.news

Create post

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

  • Windows
  • Mac OS X
  • GNU/Linux and BSD (Just get it from your distribution’s package manager)

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for “emacs” and “vi” link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

Community stats

  • 18

    Monthly active users

  • 562

    Posts

  • 2.4K

    Comments