[Cuis-dev] overriding doesNotUnderstand
Mark Volkmann
r.mark.volkmann at gmail.com
Mon Jun 10 11:16:06 PDT 2024
On Mon, Jun 10, 2024 at 11:01 AM <ken.dickey at whidbey.com> wrote:
> On 2024-06-10 07:42, Mark Volkmann via Cuis-dev wrote:
>
> > I'm learning about overriding the `doesNotUnderstand` method in a class
> > to support processing somewhat arbitrary messages. But the Smalltalk
> > editor is perhaps being too helpful. It doesn't want to let me send an
> > "unknown selector". So it's not clear to me how I can send a message
> > that will trigger my implementation of the `doesNotUnderstand` method.
> > Is there a way I can do this?
>
> When you save the method, you can just `confirm` this selector is what
> you want.
>
> It is useful to have unknown selectors, BTW to "debug code into
> existence". Just keep running the code and write code for the selectors
> as they come up as missing into the debugger.
>
> Use of #doesNotUnderstand is frequently the wrong thing to do.
>
Thanks Ken! I was finally able to get my demo code working. A fileOut is
attached.
I see how the thing I implemented is not really a good idea. I was just
trying to learn how `doesNotUnderstand` works.
I have a class method `demo` that demonstrates using my `Map` class with
the following:
map := Map new.
map firstName: 'Mark'.
map firstName print
The `Map` class has an instance variable that holds a `Dictionary`. Sending
messages to a `Map` instance accessed the `Dictionary`. This lets me
specify `Dictionary` keys with arbitrary messages. But an issue I
discovered is that this breaks if the message name matches an existing
method like `name`. I know I should just stick with sending `:at` and
`:at:put` to a `Dictionary`. This was just a learning exercise.
--
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240610/28d89600/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Map.st
Type: application/octet-stream
Size: 1243 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240610/28d89600/attachment.obj>
More information about the Cuis-dev
mailing list