On Sat, 27 Aug 2011, Thomas Mayer wrote:
- How should nested objects and arrays be handled? Should they be
handled at all?
There's really no standard way to do any kind of nesting in Pd. Several externals provide their own way of nesting things but none of them are really widespread in use. My proposals in that direction haven't gone anywhere (reference counting would have to be supported by all externals, with a slightly different Pd API, more or less).
If you are also limited to only floats and symbols for doing this, you can't even pass delimiters like "(" and ")" to indicate beginning of something or end of something, because they are already possible text strings in JSON. It's the same problem as trying to use "begin" and "end" as delimiters, just a little bit less common because parens rarely happen as single-character text strings.
It really wouldn't be that hard to implement a binbuf atom type, if it weren't for the issue of how (when) to deallocate it. I always assumed that this sort of thing ought to deallocate itself on its own when it stops being referenced, but Pd provides no means to make that ever happen.
a binbuf atom would be something that counts as one atom but can be expanded to a complete 'list'. Thus if a list represents an object that has 5 key-value pairs, and the 4th one has an object value, then you would have an atom-type sequence like :
SYMBOL FLOAT SYMBOL SYMBOL SYMBOL FLOAT SYMBOL BINBUF SYMBOL SYMBOL
and then when you use a «binbuf $8» or «list $8» messagebox, you still would have a single atom, but something like [list frombinbuf] or [binbuf2list] would expand it to a list of n elements (input message would need to contain a single atom whose type is binbuf).
It doesn't need to be called a binbuf, but that's what it's already called in Pd, though it's currently not an atom type, only a thing for long-term (non-stack) holding of a list.
- How to implement attachments (binary files) for data? Or should I
forget about this stuff and e.g. store images as base64 encoded strings?
Have a way to write them to disk ?
Lots of things are going to be complicated unless you decide to rely upon certain rarely-used externals.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC