Home > Community > Forums > Custom IC SKILL > symbol property question

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 symbol property question 

Last post Fri, Mar 1 2013 8:59 AM by Andrew Beckett. 5 replies.
Started by RVERP 28 Feb 2013 06:07 AM. Topic has 5 replies and 718 views
Page 1 of 1 (6 items)
Sort Posts:
  • Thu, Feb 28 2013 6:07 AM

    • RVERP
    • Top 500 Contributor
    • Joined on Mon, Oct 24 2011
    • Posts 27
    • Points 465
    symbol property question Reply

    I declare 3 variables

    a = 10
    b= 20
    test=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 99
    x is still unbound.

     what has happened when i did test->x = 99??

     

    • Post Points: 20
  • Thu, Feb 28 2013 7:37 AM

    • theopaone
    • Top 75 Contributor
    • Joined on Tue, Feb 12 2013
    • Cedar Park, TX
    • Posts 80
    • Points 1,190
    Re: symbol property question Reply

    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.

    Ted

    • Post Points: 20
  • Thu, Feb 28 2013 2:59 PM

    Re: symbol property question Reply

    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.

    Andrew.

    • Post Points: 20
  • Thu, Feb 28 2013 7:40 PM

    • theopaone
    • Top 75 Contributor
    • Joined on Tue, Feb 12 2013
    • Cedar Park, TX
    • Posts 80
    • Points 1,190
    Re: symbol property question Reply

     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.

    Ted

    • Post Points: 20
  • Fri, Mar 1 2013 12:05 AM

    • RVERP
    • Top 500 Contributor
    • Joined on Mon, Oct 24 2011
    • Posts 27
    • Points 465
    Re: symbol property question Reply

     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 = something
    masterlist->prop1->prop1.2 = something  else
    masterlist->prop2->prop2.1 = something new

    or is this better:

    prop1list->prop1.1 = something
    prop1list->prop1.2 = something  else
    prop2list->prop2.1 = something new

    • Post Points: 20
  • Fri, Mar 1 2013 8:59 AM

    Re: symbol property question Reply

    No problem with having nested disembodied property lists. Note that you need to initialize the sub-property list - using ncons(nil) for example:

    masterlist=ncons(nil)
    masterlist->prop1=ncons(nil)
    masterlist->prop1->subprop1="hello"
    masterlist->prop1->subprop2="test"
    masterlist->prop2=ncons(nil)
    masterlist->prop2->subprop21=23

    Then if you look at the masterlist variable it contains:

    (nil prop2 (nil subprop21 23) prop1 (nil subprop2 "test" subprop1 "hello"))

    Regards,

    Andrew.

    • Post Points: 5
Page 1 of 1 (6 items)
Sort Posts:
Started by RVERP at 28 Feb 2013 06:07 AM. Topic has 5 replies.