On 19 October 2012 12:09, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, as i promised before, here the simple smalltalk-based literal format. It based on smalltalk syntax, and so, unlike JSON, it doesn't needs to have separate parser (a normal smalltalk parser used for that).
The idea is quite simple: you can tell any object to represent itself as an 'object literal' , for example:
(1@3) asObjectLiteral --> #(#Point 1 3)
{ 1@2. 3@4. true. false . nil } asObjectLiteral
This is basically Scala's unapply function: it permits objects to expose their internal structure (in any way they choose, of course). It looks like you've written a fairly generic one that would cover most use cases. This kind of destructuring lends itself to pattern matching [1] and unification [2][3]. [1] http://www.lshift.net/blog/2011/05/15/algebraic-data-types-and-ometa2 (look for "Node>>unapply") [2] http://www.lshift.net/blog/2011/05/31/unification-pattern-matching-but-twice... [3] http://www.lshift.net/blog/2012/01/16/unifying-parts-of-structures frank