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

Gerald Klix cuis.01 at klix.ch
Thu Aug 12 08:25:17 PDT 2021


Perfect! You have mastered this stuff.
Your chain of reasoning should go into the wiki.

It's fun to answer your questions!


Best Regards,

Gerald



On 8/12/21 4:12 PM, Nicola Mingotti via Cuis-dev wrote:
> 
> Hi Gerald,
> 
> I think now i am able to parse the command "PositionableStream class >> 
> on: arg1".
> 
> please check if I understand correctly. The logic why it is so for me it 
> is too early to appreciate,
> but for now i am happy enough if i got correctly the mechanic.
> 
> -------
> PositionableStream class >> on: arg1
>     self basicNew on: arg1
> -------
> 
> . The first thing that get executed is "self basicNew"
> . self here is the class PositionalbleStream
> . basicNew is not in its methods so it will be looked into its 
> superclasses methods
> . who are the superclasses ? these:
> ------------
> PositionableStream class. " PositionableStream class "
> PositionableStream class superclass. " Stream class "
> PositionableStream class superclass superclass. " Object class "
> PositionableStream class superclass superclass superclass. " ProtoObject 
> class "
> PositionableStream class superclass superclass superclass superclass. " 
> Class "
> PositionableStream class superclass superclass superclass superclass 
> superclass. " ClassDescription "
> PositionableStream class superclass superclass superclass superclass 
> superclass superclass. " Behavior "
> PositionableStream class superclass superclass superclass superclass 
> superclass superclass superclass. " Object "
> PositionableStream class superclass superclass superclass superclass 
> superclass superclass superclass superclass. " ProtoObject "
> PositionableStream class superclass superclass superclass superclass 
> superclass superclass superclass superclass superclass. " nil "
> ----------------
> . Interesting enough at some point we have Behaviour as superclass, not 
> "Behaviour class"
> . Indeed Behaviour >> basicNew exists, and it is a primitive
> . so "self basicNew" creates a new instance from the PositionableStream 
> class
> . this is an Object PositionableStream and is has the "on:" method.
> 
> 
> bye
> Nicola
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On 8/12/21 11:31 AM, Gerald Klix wrote:
>> Maybe "doing" this little piece of code gives you some insight into 
>> classes (and Metaclasses):
>>
>> `HoverHelpMorph class withAllSuperclasses asArray inspect`
>>
>> HoverHelpMorph is just an arbitrary class with some super-classes.
>>
>>
>> HTH,
>>
>> Gerald
>>
>>
>> On 8/12/21 11:20 AM, Gerald Klix via Cuis-dev wrote:
>>> 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