Consing To Inside A Global Variable

Discussion of Common Lisp
Post Reply
mszegedy
Posts: 2
Joined: Mon May 30, 2011 2:35 pm

Consing To Inside A Global Variable

Post by mszegedy » Mon May 30, 2011 4:35 pm

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?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: Consing To Inside A Global Variable

Post by ramarren » Mon May 30, 2011 10:25 pm

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.

Post Reply