JSON in SCouchDB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JSON in SCouchDB

Igor Stasenko
On 20 June 2010 19:27, Tim Felgentreff <[hidden email]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Subclassing the Dictionary directly just didn't work on gnu smalltalk (for reasons have yet been unable to determine) - calling new on any subclass of Dictionary will throw an error.

Oh.. i see. Bad luck. File the bug report to GNU St developers :)

>
> I once had similar problems subclassing other collection classes and was told by a Squeaker that it's "better" to delegate to collections instead of subclassing them in the domain anyway. If you don't agree, feel free to ignore the changes relating to JsonObject class and I will move them to the Gnu Smalltalk diff.
>

Not in case of JsonObject , because it is naturally a dictionary of
key/value pairs, so there are a little
need for delegation.
So, by subclassing it, i eliminated an additional message sends for
better performance as well as
it gives a full Collection/Dictionary protocol available to operate
with json objects.
Originally, a JSON library was also used a delegation.

I'd like to forward this exchange to squeak-dev list, lets hear what
others thinking.
I am also would like to see this stuff portable, without the need of
external patches, even
if it means some sacrifices (i hope not much) :)

> On Jun 20, 2010, at 6:18 PM, Igor Stasenko wrote:
>
>> Tim, what is motivation to delegate json object to dictionary instead
>> of subclassing it?
>>
>> On 20 June 2010 19:12, Igor Stasenko <[hidden email]> wrote:
>>> Thank you.
>>> I will review them carefully.
>>>
>>> On 20 June 2010 15:23, Tim Felgentreff <[hidden email]> wrote:
>>>> Hi
>>>> I'm attempting to port your JSON/SCouchDB code to Gnu Smalltalk. I'm using a separate git branch to keep track of the Gnu Smalltalk specific diffs, however, I though it would be a good idea to keep the Squeak codebase as portable as possible. I'm attaching a mcz with changes I did in Squeak which don't break the tests for either JSON or SCouchDB, but make it more portable for GST.
>>>> I though I'd send them to you for review and possibly inclusion in the main repository on Squeaksource.
>>>>
>>>> Regards,
>>>> Tim
>>>>
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko AKA sig.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (Darwin)
>
> iEYEARECAAYFAkweQW4ACgkQLbWJItnd6CxXkACgwA59l35Z2/KjO6JIWq/iRrp0
> Z0cAniAdefgAo27A9pie7j2il/tdAHij
> =R55q
> -----END PGP SIGNATURE-----
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: JSON in SCouchDB

Tony Garnock-Jones-2
Igor Stasenko wrote:
>> Originally, a JSON library was also used a delegation.

Originally, the JSON library used Dictionary itself, adding the relevant
serialization method directly to Dictionary. I don't think there's any need for
a special JsonObject class. Perhaps we could switch back to using Dictionary
itself (just as we currently use String, Array, Number, etc.).

Tony

Reply | Threaded
Open this post in threaded view
|

Re: JSON in SCouchDB

Tim Felgentreff
On Jun 20, 2010, at 6:51 PM, Igor Stasenko wrote:

> On 20 June 2010 19:27, Tim Felgentreff <[hidden email]> wrote:
>> Subclassing the Dictionary directly just didn't work on gnu smalltalk (for reasons have yet been unable to determine) - calling new on any subclass of Dictionary will throw an error.
>
> Oh.. i see. Bad luck. File the bug report to GNU St developers :)
>

I got an answer on smalltalk-help (the gnu smalltalk ML), and it's a trivial solution. Still

On Jun 21, 2010, at 8:14 AM, Tony Garnock-Jones wrote:

> Igor Stasenko wrote:
>>> Originally, a JSON library was also used a delegation.
>
> Originally, the JSON library used Dictionary itself, adding the relevant
> serialization method directly to Dictionary. I don't think there's any need for
> a special JsonObject class. Perhaps we could switch back to using Dictionary
> itself (just as we currently use String, Array, Number, etc.).
>
> Tony
>

I would like that, even though I now have a solution for the subclassing problem.
Reply | Threaded
Open this post in threaded view
|

Re: JSON in SCouchDB

Hannes Hirzel
In reply to this post by Tony Garnock-Jones-2
On 6/21/10, Tony Garnock-Jones <[hidden email]> wrote:
> Originally, the JSON library used Dictionary itself, adding the relevant
> serialization method directly to Dictionary. I don't think there's any need
> for
> a special JsonObject class. Perhaps we could switch back to using Dictionary
> itself (just as we currently use String, Array, Number, etc.).
>
> Tony

I like the idea of directly adding a few methods to 'Dictionary'

--Hannes