[Cuis-dev] The Cuis-Smalltalk Book Exercise 2.3: Count of methods

Ezequiel Birman ebirman77 at gmail.com
Sun Dec 3 06:40:38 PST 2023


It is already done! Thanks to Hilaire

On Sun, 3 Dec 2023 at 14:37, Luciano Notarfrancesco <luchiano at gmail.com>
wrote:

> I think we removed those messages from String a few years ago. Someone
> should fix the exercise…
>
> On Sun, Dec 3, 2023 at 21:17 Ezequiel Birman via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> To answer myself, the fact that we can evaluate `'' raisedTo: n` without
>> error seems like an unforeseen consequence of `#adaptToCollection:andSend:`
>> relying on `#collect` and how the latter works with empty collections.
>>
>> On Fri, 1 Dec 2023 at 21:56, Ezequiel Birman <ebirman77 at gmail.com> wrote:
>>
>>> The exercise is:
>>>
>>>> How many methods are there in the arithmetic method category of the
>>>> String class?
>>>>
>>>
>>> There are no messages categorized as arithmetic in String but in
>>> CharacterSequence, which String subclassifies. Maybe it was different
>>> before; Squeak Strings implement arithmetic messages, exactly those
>>> mentioned in the solution to the exercise:
>>>
>>>> the count of methods in the last right panel is 6: *, +, -, /, // and
>>>> \\.
>>>>
>>> But `String allMethodsInCategory: 'arithmetic'` in both Cuis and Squeak
>>> evaluates as:
>>>
>>>>  #(#* #+ #- #/ #// #\\ #raisedTo:)
>>>>
>>> Seven methods and yes! you can raise the empty string to the power of n
>>> for n ∈ Number. WAT! The result is another empty string :) Are we able to
>>> do this because of historical reasons? Strings in Squeak can be added E.g
>>> `'3' + '4'` is the string '7'.
>>>
>>> Btw, I'm sharing my annotations
>>> <https://hyp.is/k4BuJpCLEe6_Z59nfniWQQ/cuis-smalltalk.github.io/TheCuisBook/A-brief-introduction-to-the-system-Browser.html>
>>> via hypothes.is publicly but you'll need to install the Chrome plugin
>>> or the unofficial Firefox extension
>>> <https://github.com/diegodlh/unofficial-hypothesis-extension> to see
>>> them. I've requested to use their proxy so you don't have to, but it might
>>> take some time. Once you install any of the plugins you'll be able to read
>>> and write comments. The UI looks like this:
>>> [image: imagen.png]
>>>
>>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231203/3da70276/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagen.png
Type: image/png
Size: 138874 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231203/3da70276/attachment-0001.png>


More information about the Cuis-dev mailing list