[squeak-dev] Should you override #doesNotUnderstand: and #respondsTo: together?

Jakob Reschke forums.jakob at resfarm.de
Fri Jan 31 17:16:51 UTC 2020


Regarding canUnderstand:, maybe it's time for the third boolean called "it
depends" or "maybe". ;-)

Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> schrieb am
Fr., 31. Jan. 2020, 10:43:

> > Question is, should X class>>canUnderstand: be overwritten, too?
>
>
> This would not be possible in my example, would it? Each json object
> understands different keys ... This is also why I favor #respondsTo: over
> #canUnderstand: in general.
>
>
> Best,
>
> Christoph
> ------------------------------
> *Von:* Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im
> Auftrag von Tobias Pape <Das.Linux at gmx.de>
> *Gesendet:* Freitag, 31. Januar 2020 10:30:20
> *An:* The general-purpose Squeak developers list
> *Betreff:* Re: [squeak-dev] Should you override #doesNotUnderstand: and
> #respondsTo: together?
>
>
> > On 31.01.2020, at 10:14, Thiede, Christoph <
> Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
> >
> > Hi all,
> >
> > just struggled over the fact that Json objects provide access to their
> keys via #doesNotUnderstand:, but they do not override #respondsTo:.
> Example:
> >
> > json := Json readFromString: '{"foo": 42}'.
> > json foo. "42"
> > json respondsTo: #foo. "false"
> >
> > Question: Is this discrepancy indeed desired behavior? Or should we
> rather always try to override #doesNotUnderstand: and #respondsTo: together?
>
> This is actually done very seldom, IIRC.
> But maybe a good pattern, tho. Question is, should X class>>canUnderstand:
> be overwritten, too?
>
> Best regards
>         -Tobias
>
> >
> > Best,
> > Christoph
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200131/9e0f2841/attachment.html>


More information about the Squeak-dev mailing list