I declare 3 variables
a = 10b= 20test=list('a 'b)
now I do test->x = 99
now test = (a x 99 b)
So my list has become 4 items long, containing symbols a,b and x, and a value 99x is still unbound.
what has happened when i did test->x = 99??
You kind of created a disembodied property list (DPL). It is not a correctly formatted list which should start with a nil and contain symbol/value pairs.
list( nil 'a "valueForA" 'b 3.2 'x 99 )
As for x, it is a symbol used as a key in your list. It has no value. In a properly formatted DPL, you would evaluate test->x and have returned the value 99
I'm not sure what you will get with your malformed DPL.
In reply to theopaone:
There is absolutely no problem with having a disembodied property list with something other than nil as the first element - in fact I have used this to allow me to store something useful in that place - to allow me to have assoc lists of dpls.
The DPL will work fine - you can use test->x to retrieve the value. The fact that there is a strange dummy value at the end wouldn't be a problem. Not sensible, but not a problem either.
In reply to Andrew Beckett:
I remember using the first element in a DPL to hold a value but considered it a quirk that could be "fixed" in a later release. I never even thought of creating a DPL out of an existing list like that, it looks like a hard to find bug wating to byte at some later point.
Ok, thanks I lookes at the chapter in the manual and understand now.
But what I was wondering, is there an reason not to make a DPL in a DPL, like this:
masterlist->prop1->prop1.1 = somethingmasterlist->prop1->prop1.2 = something elsemasterlist->prop2->prop2.1 = something new
or is this better:
prop1list->prop1.1 = somethingprop1list->prop1.2 = something else
prop2list->prop2.1 = something new
In reply to RVERP:
No problem with having nested disembodied property lists. Note that you need to initialize the sub-property list - using ncons(nil) for example:
Then if you look at the masterlist variable it contains:
(nil prop2 (nil subprop21 23) prop1 (nil subprop2 "test" subprop1 "hello"))