On 19 October 2012 13:56, Igor Stasenko <siguctua@gmail.com> wrote:
On 19 October 2012 13:40, Frank Shearar <frank.shearar@gmail.com> wrote:
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].
well, my intent was to demonstrate a simple and straightforward way how you can store virtually object as literal (in string)
ahem .. virtually *any* object.
and read it back. and keep it fairly human readable, and without need to use JSON ;)
i don't mind, if it lends to extra stuff, that's even better :)
[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
-- Best regards, Igor Stasenko.
-- Best regards, Igor Stasenko.