On 2016-03-31 18:06, Richard Gaskin wrote:
When we use array syntax on custom property sets we have effectively a
sort of two-dimensional array.  Would be nice to extend that deeper,
but I'll take what I get.

Well, that 'anomaly' is basically about the fact that custom property set syntax is 'the wrong way round' (in some sense) to allow arbitrarily nested [] on custom properties to work. If custom property sets had never existed, and you just had custom properties, then we could have had:

  the foo of tObject - the foo custom property
the foo["bar"] of tObject - the bar key of the (array valued) foo custom property the foo["bar"]["baz"] of tObject - the baz key of the bar key of the (array valued) foo custom property

However, what we have is:

  the foo of tObject - the foo custom property
the foo["bar"] of tObject - the bar custom property in the foo custom property set

The second form here is very different from the second form above. This is a bit of a shame really, as it would have been much easier to think about if we could have made the equivalence:

  the foo[a]...[z] of tObject === (the foo of tObject)[a]...[z]

But when we put an array into a custom property value such as:

put "foo" into bar[1]
set the uBar of btn 1 to bar

...it seems we can store that even though it hasn't been explicitly serialized.

So my hunch is that when we do that the engine is using the same
serialization it uses for arrayEncode, and when retrieving the array
it automatically runs it through the internal equivalent of
arrayDecode.

Is that correct?

Well, implementation-wise, the 'default custom property set' is the custom property set with name 'empty'; and internally each object has a linked list of named custom property sets. Each custom property set does and always had the same representational power as a LiveCode variable. So when nested arrays were added, custom properties gained the ability to hold arrays too. Since 7, all a custom property set is is a (name, array) pair, where the array part maps custom property names in that set to their values.

If not, by what sorcery are array values serialized when stored as
persistent property values?

Well, there was a fair bit of sorcery involved way back when nested arrays were added as we wanted to try and squeeze them into the file format without breaking backwards compatibility.

However, the principal motivation (if I remember correctly, at least - we are going back many many years here) for arrayEncoding was to enable custom property sets to serialize array values.

Anyway, to summarise, when in memory a custom property set is just an array (which is looked up in a linked list by name) - this array maps custom property names to values. When written out to disk (in 7+ format - pre-6.7 format had to do horrendous things which I never want to have to look at again) each custom property set is serialized as the name followed by the arrayEncoding of the array.

Hopefully that all makes sense...

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to