[Cuis-dev] reflection and questionable tab completion

Hernán Wilkinson hernan.wilkinson at 10pines.com
Fri Jun 14 11:41:24 PDT 2024


>
>
> Thanks so much for explaining all of that!
>

:-)


> What is the source of the blue messages? For example, what does it think
> that `Smalltalk packages` represents if not a supported message?
>

All object respond to the message #respondsTo:  :-)
So, "Smalltalk respondsTo: #pacakges" --> false


> What's the value in tab completion showing them if they aren't really
> supported messages?
>

That because it is a dynamically typed language you are allow to send a
message to an object that it does not answer at the moment... but it will
eventually, for example you can evaluate "Smalltalk qqq" it will open the
debugger because Smalltalk does not respond to that message, but you can
press the "Create" button in the debugger, implement the #qqq message and
after implementing it press "Proceed" and uala! Now Smalltalk responds to
#qqq :-)

That is the power of a dynamically typed language :-)

Hernan.

>
> On Fri, Jun 14, 2024 at 12:43 PM Hernán Wilkinson <
> hernan.wilkinson at 10pines.com> wrote:
>
>> Hi Mark,
>>  Smalltalk is a dynamically typed language, therefore the autocompletion
>> tries to do its best due to the lack of type info.
>>  For sure you noticed that some selectors that the autocomplete shows are
>> in black and some are in blue. The ones in black are the ones that for sure
>> the receiver of that message will answer, the ones in blue are the ones
>> that the autocomplete does not know.
>>  In your example, the selector packages is in blue because Smalltalk is
>> an object whose type is well known by the environment and it will not
>> answer that message. (Please do not confuse Smalltalk the
>> language/environment with Smalltalk the object)
>>  Just to clarify, Smalltalk is a global var that references an object
>> instance of SystemDictionary, if you write "Smalltalk " (without the
>> quotes) and press tab (*), the autocompletion will show you all the
>> messages that Smalltalk will answer for sure. If you press "p" it will show
>> you all the selectors that start with p, but if you press "pa" you will see
>> they are in blue, that means that Smalltalk will not answer those messages.
>>  Inferring what messages Smalltalk will answer is simple due to what I
>> said in the previous paragraph, but most of the cases are not like that.
>> For example, if you have the method "m1: something", what is the type of
>> "something"? how can we infer the messages it will answer? There are many
>> techniques, for example type inference (but it is slow and not "complete"),
>> another is something we implemented in Cuis called "LivedTyping" where
>> types of variables are collected dynamically and that info is used in all
>> the tools, specially in the autocompletion.
>>  The UX with LiveTyping is completely different because it is like having
>> tools of a statically typed language but in a dynamically typed one. If you
>> want to try it, download CuisUniversity from
>> https://sites.google.com/view/cuis-university/descargas?authuser=0 that
>> has LiveTyping installed. (The site is in Spanish, but you will understand
>> :-) ).
>>
>>  I hope I answered your question, it is an interesting topic :-) If you
>> have questions let me know.
>>
>> Cheers!
>> Hernan.
>>
>> (*) For the autocompletion to open when you press tab this preference
>> must be set:
>> Preferences name: #spaceTabOpensAutoCompletion category: #gui value: true.
>>
>>
>>
>> On Fri, Jun 14, 2024 at 2:14 PM Mark Volkmann via Cuis-dev <
>> cuis-dev at lists.cuis.st> wrote:
>>
>>> I'm learning about reflection in Smalltalk and trying out a bunch of
>>> related methods. When I enter Smalltalk and part of a message name in a
>>> Workspace and press the tab key I get lots of suggested completions. But
>>> many of them give me MessageNotUnderstood when I "Print it". For
>>> example:
>>>
>>> Smalltalk packages
>>>
>>> Why would it suggest completions that aren't really implemented?
>>>
>>> --
>>> R. Mark Volkmann
>>> Object Computing, Inc.
>>> --
>>> Cuis-dev mailing list
>>> Cuis-dev at lists.cuis.st
>>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>>
>>
>>
>> --
>>
>> *Hernán WilkinsonAgile Software Development, Teaching & Coaching*
>> *Phone: +54-011*-4893-2057
>> *Twitter: @HernanWilkinson*
>> *site: http://www.10Pines.com <http://www.10pines.com/>*
>> Address: Alem 896, Floor 6, Buenos Aires, Argentina
>>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>


-- 

*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240614/227e4927/attachment.htm>


More information about the Cuis-dev mailing list