Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Fake" global lexical variables in Common Lisp

It is stated in section "Global variables and constants" of the Google Common Lisp Style Guide that:

"Common Lisp does not have global lexical variables, so a naming convention is used to ensure that globals, which are dynamically bound, never have names that overlap with local variables.

It is possible to fake global lexical variables with a differently named global variable and a DEFINE-SYMBOL-MACRO. You should not use this trick, unless you first publish a library that abstracts it away."

Can someone, please, help me to understand the meaning of this last sentence.

like image 800
Paulo Tomé Avatar asked Jun 20 '13 23:06

Paulo Tomé


1 Answers

The last sentence,

You should not use this trick, unless you first publish a library that abstracts it away.

means that if you do something that simulates global lexical variables, then the implementation of that simulation should not be apparent to the user. For instance, you might simulate a global lexical using some scheme using define-symbol-macro, but if you do, it should be transparent to the user. See Ron Garret's GLOBALS — Global Variables Done Right for an example of “a library that abstracts it away.”

like image 126
Joshua Taylor Avatar answered Oct 02 '22 15:10

Joshua Taylor