[Cuis-dev] smalltalk newbie - Complex
Jonathan Kelly
jonkelly at fastmail.fm
Sat Sep 27 15:36:39 PDT 2025
On 27/9/25 11:43, ken.dickey at whidbey.com wrote:
> On 2025-09-26 17:23, Jonathan Kelly via Cuis-dev wrote:
>> Hi,
>>
>> I'm playing with Cuis smalltalk, and building a Complex class, so far
>> so good. But I want to add an "isComplex" method on Object, and
>> an "asComplex" method on Number, but I can't find a way to tell Cuis
>> that the new methods belongs to the Complex package.How do I make all
>> my changes belong to the Specific package they're related to?
>
> This is a good exercise to learn about packages.
>
> The typical practice is to create a method category with $* and the
> name of the class the methods are related to.
>
> In this case, method category '*Complex' in class Object would have
> your method 'isComplex'.
>
> BTW, after you finish, you could use a file list to package browse:
> Cuis-Smalltalk/Cuis-Smalltalk-Dev/Packages/Features/Complex.pck.st
> or open a Workspace and invoke
> Feature require: 'Complex'.
> And see how someone else did it.
>
> HTH,
> -KenD
Thanks Ken.
I did think a little strange there wasn't a Complex class somewhere ...
glad to find the Features thing ...
Coincidentally, talking about Complex, I think a problem with Smalltalk
is that for some (or is that many), it rubs your nose in the fact you
may not be as smart a programmer as you imagined. :)
Jonathan.
More information about the Cuis-dev
mailing list