| VLIST XTRA HELP: HOW DIRECTOR STORES DATA TYPES |
| All data types are not created equal when it comes to memory storage. Some are stored by value, which means that a separate copy of the data is made each time it is used in the list, copied to a variable, or passed as an argument to a handler. Integers, floats and symbols are examples of data types that are stored by value. Other data types are stored by reference, which means that a pointer to the item's memory location is stored, instead of a new separate copy of the data.The data types member.media and member.image, image(), strings, rects and points are stored by reference. If the item stored by reference appears in a list multiple times, multiple pointers to it are stored rather than multiple separate copies of it. You can see this by typing the following in the message window: aList = [ ] append aList, member(1).media append aList, member(1).media append aList, member(1).media put aList -- [(media eefe4e0), (media eefe4e0), (media eefe4e0)] 0EEFE4E0 is the address in memory where member(1)'s media is stored. STRINGS Strings are stored by value in Director 7 and 8. In Director 8.5 they are stored by reference. You can use vList's isSame function to determine if two variables are pointing to the same memory location or not. A = "some text" B = A In Director 7 and 8, string B is a separate identical copy of A: put isSame(A, B) -- 0 In Director 8.5 both B and A are pointers to the same memory location: put isSame (A, B) -- 1 In Director 8.5 and later, if you go on to modify string B, Director then makes a separate copy of the original and stores it in B: B = B & " more text" put isSame(A, B) -- 0 At this point A and B occupy two separate memory locations and the reference count for A, which still points to the original string, is decremented by 1. Making copies of large strings each time they were passed to handlers or copied to variables really slowed down some operations in previous versions of Director. This optimization of string storage in D8.5 is a welcome enhancement, that was designed to be transparent to Lingo coders. In Director 11, strings are stored as Unicode (UTF8) data. vList will attempt to transparently convert strings to/from UTF8 and the older MacRoman/Latin1 character mappings, used until Director MX2004. However, some characters might not be translatable in double byte languages when going from Director 11 to older versions, and vice-versa. Also, strings that are part of the media of members will not be inspected or translated. These members need to be upgraded using the upgrade movies mechanism that exists in Director 11. FLOATS Prior to Director 8.5, Director reserved 64-bits (8 bytes) for each floating point variable. In Director 8.5 there is a more economical 32-bit (4 byte) floating point data type, which can store floating point numbers with up to 8 digits before the decimal and nothing (0) after the decimal. The storage size required for a float is determined transparently by Director and not normally apparent to the Lingo programmer. However, vList can distinguish between the two float types under Director 8.5 and stores the smaller 32-bit float in its native format both in vList members and on disk. vList's float32P function returns the storage requirement of a float under Director 8.5.