Hi guys

we are looking at STON and ObjectLiterals with Christophe and for handling metadata.


And I was brainstorming.... I was wondering if it would be possible to have a bit more use of self evaluating

for example
    1@3
    #k -> 2 instead of (Association #k 123)


my brainstorming is how could we minimize new syntactic constructs and still support a literal object format.
So object literal cover that so may be this is good.

    1@3 as (Point 1 3)
    and
    #k -> 123 as (Association #k 123)

So I'm not clear but this is interesting to think about it.
I would like to have also a dictionary literal syntax.... but this another story.

Stef

PS: Sven I added support for Association into the ObjectLiteral project to see how it works.









I took Igor's initial code and created a new project:

    http://smalltalkhub.com/#!/~SvenVanCaekenberghe/ObjectLiterals/

and I added ObjectLiteralParser to convert any Character Stream or String into a Smalltalk Literal Array and eventually into an Object.

This proof of concept moves the ObjectLiteral format/notation away from the Smalltalk compiler and will help us discuss more concretely the actual details of the specification (which is still not 100% finished).

I also added 12 unit tests and cleaned up the code and comments.

Please have a look at the code.

This is one of the tests:

ObjectLiteralParserTests>>#testMixed1
    | input output |
    input := '
        #(Array
            1
            foo
            #''foo-#bar''
            true
            false
            nil
            3.14159
            -100
            ''string''
            (#OrderedCollection 7 8 9)
            #(Set 10)
            (Dictionary
                x 1
                y 2) )  '.
     output := {
        1.
        #foo.
        #'foo-#bar'.
        true.
        false.
        nil.
        3.14159.
        -100.
        'string'.
        OrderedCollection withAll: #(7 8 9).
        Set with: 10.
        Dictionary newFromPairs: #(x 1 y 2 ). }.
    self assert: (self parserOn: input) nextObjectLiteral equals: output

I like this format, its simplicity and elegance is appealing, it offers distinctive advantages in the Smalltalk context while its slight readability disadvantage is acceptable. Like any format it is a compromise and a tradeoff, but a rather good one.

Regards,

Sven

--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill


Reply via email to