List vs. Set Attributes


(Alvin) #1

Can somone please provide a practical example where list attributes would be used against set attributes and vice versa? I’ve looked at all the dog, pear, peach, zebra…examples and doesn’t really ring.

Here’s how I see a use of list & set attributes: ( I need a little nudge to see how I can use them in this context)

LEt’s say I want to arrange all my software applications by name so I create a List attribute for all the applications by name (that being the raw “deposit in my database”; then I would use set attributes to categorize all the applications by, e.g.: platform, operating system, manufacturer, type ,device, etc. Am I on the right track here? I can’t discern how these two attributes are used and what the benefit would be of one over the other…


(Mark Anderson) #2

Nope. Both are a list, i.e multi-value attributes than can hold zero, one, or more values. By comparison, changing a String value changes the only value stored by that attribute.

A List-type stores all the values applied, in the order applied. A List can have duplicate values , and in some cases that’s a valid and useful thing.

A Set-type is also a list but de-dupes values, so if you add the same value again unlike a List-type that value is stored once, i.e the list is de-duped. Also, a Set may alter it’s stored value order - but generally doesn’t. A practical example is $KeyAttributes - a Set. It’s most unlikely you’d want the same attribute as a KA more than once, so a Set is a boon. But if you need to make a list of the order of people posting if a thread in a forum (where some post more than once), de-duping would make that impossible.

OK, that sounds confusing, but way back (circa .v4.5) in Tinderbox’s life the only list-type attribute was a Set. Now that both Set and List have dot-operators like .unique (de-dupes list) and .sort the difference between the two has lessened.

aTbRef is probably your best reference for a) system attribute data-types and b) the data-type returned by action code functions. Note that over time some action functions that used to return Sets, may now return Lists.


(eastgate) #3

A set either contains a value, or it doesn’t. Sets can’t have more than one copy of a value. Checking whether a set already has a value is very fast. The order in which items appear in a set is arbitrary and subject to change — that’s how Tinderbox makes find things faster.

A list is more general. Lists can be ordered however you like. Lists might the same item several times. If you arrange a list one way, it will stay that we until you change it.