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

前端 未结 7 1517
时光说笑
时光说笑 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:40

    Adding a side note to the above answers:

    Newcomers to Lisp often are not sure exactly what symbols are for, besides being the names of variables. I think the best answer is that they are like enumeration constants, except that you don't have to declare them before using them. Of course, as others have explained, they are also objects. (This shouldn't seem strange to users of Java, in which enumeration constants are objects too.)

提交回复
热议问题