This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Consing To Inside A Global Variable

2 posts · 747 views

Hullo. Noob here. I'm trying to stick a symbol deep inside a global variable. I'm writing a function to do it for me, but I can't figure out how to stick a symbol inside a global variable… what I have currently is a defparameter defining a variable as itself consed to something… but this is a top-level cons. How do I cons to deeper levels?

Re: Consing To Inside A Global Variable

Typically for non-trivial application you would use a proper datastructure, since conses are somewhat finicky and best treated as immutable. See for example Practical Common Lisp for use of arrays and objects.

Also I do not really understand what you mean. Variables are bound to objects, "stick a symbol deep inside a global variable" doesn't really mean anything. If you want to add a symbol to some object, the that object being pointed to by a global variable is irrelevant. If you mean that you have a variable pointing at a cons structure which shares structure with something else, then don't do it if you intent to mutate anything.