[Cuis-dev] [IMPROV] Add convenience method to read JSON strings

Gerald Klix cuis.01 at klix.ch
Thu Aug 12 02:20:16 PDT 2021


Hi Nicola,

Please see below.

On 8/12/21 10:17 AM, Nicola Mingotti via Cuis-dev wrote:
> 
> Hi Gerald,
> 
> On 8/12/21 9:11 AM, Gerald Klix wrote:
>> May I suggest to to implement it this way:
>> --- snip ---
>> Json readFrom: aString readStream
>> --- snap ---
>> (See SequenceableCollection>>#readStream, inherited by String))
>>
> your version is nicer to the eye ;)
But probably slower without an inlining JIT. ;)
> 
> There is something i don't understand though. I can arrive up to
> PositionableStream class>> on:
> ---------------
> on: arg1
>      ^ self basicNew on: arg1.
> ---------------
> After that, I can't find where "basicNew on:" is implemented.
I feared for some time,
that you might come up with this sort of question :»]

For most #basicNew-sends the method Behavior>>#basicNew
will respond. Please note it's on the instance side of
Behavior.

In anticipating the obvious next question:

How does this all work?

This is a nice article about classes and meta-classes,
explaining their history and providing a side-look
into other programming languages
https://courses.cs.washington.edu/courses/cse341/04wi/lectures/17-smalltalk-classes.html

This article contains some words by Alan Kay and
quotes by Peter Deutsch about the Metaclass
design decision:
http://worrydream.com/EarlyHistoryOfSmalltalk/
> 
> 
>> If your JSON documents are bigger, it might be more efficient
>> to convert the HTTPSocket to a SocketStream and read directly from
>> it, but I do not know whether this is possible without much effort.
> 
> Actually the JSON strings I send/receive can be a bit large. Because 
> they represent objets with inside
> packed quite a bit of information e.g. pictures. I would say never 
> larger then 1 MByte, if possible.
> 
> Still at the moment I will not worry about efficiency. I am trying to 
> convert a Ruby+Mongo
> server side of an app into Cuis. I have time till end of the month to 
> make it work.
IC, I hope you are allowed to publish the results of your work.
> 
> For the moment I am going to replicate the database as a list of objects 
> in memory,
> I will consider persistency better in a second step ;)
My own attempts at this topic are not to successful for the time being:
http://the_haver.klix.ch/#my-journey-into-databases


> 
> Bye
> Nicola
> 
> 
> 
>>

--- snip/snap ---


Best Regards,

Gerald


More information about the Cuis-dev mailing list