Fork me on GitHub
#off-topic
<
2018-01-03
>
odie17:01:13

Does anybody know why the word “form” is used in “lisp form”? There are various other pieces of info that defines “lisp form” identically to “expression”. If that’s the case, then why weren’t “special forms” called “special expressions” instead? I’ve been curious about this for some time. Would really appreciate being pointed towards some resources that might explain the origin of the word choice.

tbaldridge17:01:45

Although that's the technical definition, I think most people use them interchangeably.

odie17:01:45

@tbaldridge thanks for that! So a “form” actually refers to the internal representation an interpreter has after the reader is done processing the expression?

tbaldridge17:01:33

yes, but if I saw one used in either situation I wouldn't bat an eye

odie17:01:35

Any idea why the word “form” was chosen? Is there some kind of historic reason? Or maybe a reason rooted in a field outside of CS? Just an interesting word choice if it’s actually referring to an AST.

bronsa17:01:52

a form is not an AST

bronsa17:01:56

1 is a form

odie17:01:37

Couldn’t a ast consist of a single item that represents the number 1?

dpsutton18:01:35

ast nodes generally have a bit more information and overhead that the single value. A leaf node might just essentially be the value 1 but that's a pretty bare representation

tbaldridge18:01:40

A AST normally contains a bunch of compiler metadata in addition to the form itself.

dpsutton18:01:39

brandon bloom has a playground for evaluators, ast,s etc at https://github.com/brandonbloom/kovasir you can see what an ast for 1 looks like in his simple example: {:op :const, :value 1} and a more complicated form: (let [x 1 y 2] (+ x y))

{:op :let,
 :name x,
 :init {:op :const, :value 1},
 :expr {:op :let,
        :name y,
        :init {:op :const, :value 2},
        :expr {:op :call,
               :f {:op :ref, :name +},
               :args [{:op :ref, :name x} {:op :ref, :name y}]}}}

dpsutton18:01:00

super neat stuff. stumbled on it last night and was reading and playing around

justinlee19:01:33

@odie You made me curious. McCarthy credits Alonzo Church with coining the term “form” in 1941 (!) to distinguish from a “function.” Check out part (c) of page 6 of this paper: http://www-formal.stanford.edu/jmc/recursive.pdf