Why is the hyphen conventional in symbol names in LISP?

后端 未结 3 1804
深忆病人
深忆病人 2021-02-14 22:54

What\'s the reason of this recommendation? Why not keeping consistent with other programming languages which use underscore instead?

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 23:02

    I think that LISP uses the hyphen for two reasons: "history" and "because you can".

    History

    LISP is an old language, and in the early days typing an underscore could be challenging. For example, the first terminal I used for LISP was an ASR-33 teletype. On some hosts and teletype models, the key sequence for the underscore character would be interpreted as a left-pointing arrow (the assignment operator in Smalltalk). Hyphens could be typed more reliably.

    Because You Can

    In LISP, there are no infix operators (well, few). So there is no ambiguity concerning whether x-1 means "x minus 1" or "x hyphen 1". The early pioneers liked the look of the hypen for multiword symbols (or were stuck on ASR-33s as well :).

提交回复
热议问题