• 0 Posts
  • 2 Comments
Joined 11 months ago
cake
Cake day: October 17th, 2023

help-circle

  • Not necessarily. If any group of things are the fundamental data types, it’s probably “streams” and “code”.

    (read) still reads the input character by character, just like any other language. The difference in Lisp languages is that, rather than simply collecting those characters into a vector and calling it a “string”, it’s incrementally parsing the input as code through the language compiler while reading it in.

    The default mode of the compiler is to interpret code as lists (as in the list data type) of either lists or symbols (this is, obviously, a massive oversimplification of the details). So (read), which treats input as code, by default interprets a single-word normal text input as a symbol.

    On the other hand, in the case of strings, the Lisp reader reads in a ‘“‘, which triggers a ”string mode” (a reader macro, if you’re familiar with Lisp terminology) that collects characters until the next ‘“‘ character and then stores them in a vector wrapped in a String object. Similarly, if a ‘word’ in the input is purely made of digits, then instead of making a symbol most Lisp interpreters (including Emacs Lisp) convert it into a number object of some sort.

    So besides being the default, symbols and lists aren’t necessarily special. What is special is that all instances of (read) involve a text input (a stream of characters) being parsed into a data structure in code.

    The fact that this is the behavior of the default reading function (there are other functions if you want to get just string input) is an instance of the fundamental nature of all Lisps: there is no difference between data and code, and so we should be able to treat data as code and code as data without friction. This is one of the key features of all Lisp languages, and an inherent advantage of their structure in comparison to other modern forms of human-computer interaction.