What is the difference between a variable and a symbol in LISP?

前端 未结 7 1599
时光说笑
时光说笑 2021-01-31 09:59

In terms of scope? Actual implementation in memory? The syntax? For eg, if (let a 1) Is \'a\' a variable or a symbol?

7条回答
  •  灰色年华
    2021-01-31 10:36

    Lisp uses environments which are similar to maps (key -> value) but with extra built-in mechanisms for chaining environments and controlling bindings.

    Now, symbols are pretty much, keys (except special form symbols), and point to a value,
    ie function, integer, list, etc.
    Since Common Lisp gives you a way to alter the values, i.e. with setq, symbols in some contexts
    (your example) are also variables.

提交回复
热议问题