4

I'm reading GNU Emacs Lisp Reference Manual, and I see the phrase "hash notation".
Two places in the document seem to have different interpretations, so I have 2 questions.


  1. 2.1 Printed Representation and Read Syntax:

    ...... some types have no read syntax, ....... These objects are printed in hash notation, which consists of the characters ‘#<’, ..., and a closing ‘>’. For example:

    (current-buffer)
         ⇒ #<buffer objects.texi>
    

    OK, doc says that hash notation is something like "#<...>".

  2. 2.2 Special Read Syntax:

    Emacs Lisp represents many special objects and constructs via special hash notations.

    #<…>’ ......

    ##’ ......

    ......

    ?C

  • But here it also implies that some of the above notations (#<...>, ##, ?C, ...) are also hash notation. Doesn't this contradict the last one?

  • Why does the name "hash notation" include "hash"?

5
  • 2
    To answer (only) your last question - many call the character # the hash mark or simply hash. Jan 7, 2023 at 16:36
  • 2
    @HighPerformanceMark I am not a native English speaker, and I looked it up in the dictionary as "number sign". This is the first time I know it also has the name "hash mark", thanks! Non-native English speakers might associate it with the "hash" of the "hash function", just like me (
    – shynur
    Jan 7, 2023 at 17:04
  • 1
    Please submit this as a bug or enhancement request, to get the doc clarified: M-x report-emacs-bug. If the doc wants to use or introduce such a term then its uses of the term should be clear/consistent.
    – Drew
    Jan 7, 2023 at 18:13
  • 1
    The # has many names. In addition to "number sign" and "hash" it is also called "pound sign" and "octothorpe". (BTW a "hashtag" is a "tag" that starts with a # "hash")
    – amitp
    Mar 4, 2023 at 17:59
  • @amitp: thx. BTW, I read your article on A star algorithm a few months ago... Great article! I also recommended it to my classmates.
    – shynur
    Aug 29, 2023 at 20:01

3 Answers 3

1

I’m not really sure that there is a widely–recognized name for these things in Emacs Lisp. The language has grown and changed over time, and things have been added to the language as needed. You could look into the version control history of the Elisp manual to find out more about how it has changed over time. I am sure that they would consider improvements to it as well. You could fix it by simply inserting another sentence after the #<…> example saying something like “The # character also introduces these other syntactic elements recognized by the reader”. Also, I have no idea why the character syntax (?C) is even on that page.

The use of # in Lisp syntax is influenced by other Lisps such as Common Lisp, where the # character indicates the use of a reader macro. The Common Lisp Specification calls it a non–terminating dispatching macro character, which is a long–winded way of saying that the character after the # tells the reader which macro to invoke. But notice that it never actually names the syntactic elements themselves; it just says that they all dispatch to reader macros.

4

Just for the second question:

The “Hash Notation” is just a kind of notation using “#”.
The mark “#” is named “hash mark”, so there is nothing to do with “hash function”.

2

It seems that the GNU Emacs Lisp Reference Manual has actually cleared up this misunderstanding.

See Chapter 8 Hash Tables:

Hash notation, the initial ‘#’ character used in the printed representations of objects with no read representation, has nothing to do with hash tables.


This is a belated explanation, IMHO, since the term “Hash Notation” has been covered since Chapter 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.