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?
Best,
Christoph
On 31.01.2020, at 10:14, Thiede, Christoph Christoph.Thiede@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
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@lists.squeakfoundation.org im Auftrag von Tobias Pape Das.Linux@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@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
Regarding canUnderstand:, maybe it's time for the third boolean called "it depends" or "maybe". ;-)
Thiede, Christoph Christoph.Thiede@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@lists.squeakfoundation.org im Auftrag von Tobias Pape Das.Linux@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@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
When would you use this third boolean concretely? To me, this sounds rather like an overengineering solution, maybe premature optimization, for now ... :-)
Best,
Christoph
________________________________ Von: Squeak-dev squeak-dev-bounces@lists.squeakfoundation.org im Auftrag von Jakob Reschke forums.jakob@resfarm.de Gesendet: Freitag, 31. Januar 2020 18:16:51 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] Should you override #doesNotUnderstand: and #respondsTo: together?
Regarding canUnderstand:, maybe it's time for the third boolean called "it depends" or "maybe". ;-)
Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.demailto:Christoph.Thiede@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@lists.squeakfoundation.orgmailto:squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Tobias Pape <Das.Linux@gmx.demailto:Das.Linux@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@student.hpi.uni-potsdam.demailto:Christoph.Thiede@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
*maybe* it was also a joke :-)
Thiede, Christoph Christoph.Thiede@student.hpi.uni-potsdam.de schrieb am Fr., 31. Jan. 2020, 18:22:
When would you use this third boolean concretely? To me, this sounds rather like an overengineering solution, maybe premature optimization, for now ... :-)
Best,
Christoph
*Von:* Squeak-dev squeak-dev-bounces@lists.squeakfoundation.org im Auftrag von Jakob Reschke forums.jakob@resfarm.de *Gesendet:* Freitag, 31. Januar 2020 18:16:51 *An:* The general-purpose Squeak developers list *Betreff:* Re: [squeak-dev] Should you override #doesNotUnderstand: and #respondsTo: together?
Regarding canUnderstand:, maybe it's time for the third boolean called "it depends" or "maybe". ;-)
Thiede, Christoph Christoph.Thiede@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@lists.squeakfoundation.org im Auftrag von Tobias Pape Das.Linux@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@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
Hm, maybe we will never now - the crux of ternary logic ;-)
But actually, I wonder whether any of these calls to "something class canUnderstand: aSelector" is useful, shouldn't we rather replace a big part of them with "something respondsTo: aSelector"?
________________________________ Von: Squeak-dev squeak-dev-bounces@lists.squeakfoundation.org im Auftrag von Jakob Reschke forums.jakob@resfarm.de Gesendet: Freitag, 31. Januar 2020 18:23:19 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] Should you override #doesNotUnderstand: and #respondsTo: together?
*maybe* it was also a joke :-)
Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.demailto:Christoph.Thiede@student.hpi.uni-potsdam.de> schrieb am Fr., 31. Jan. 2020, 18:22:
When would you use this third boolean concretely? To me, this sounds rather like an overengineering solution, maybe premature optimization, for now ... :-)
Best,
Christoph
________________________________ Von: Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.orgmailto:squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Jakob Reschke <forums.jakob@resfarm.demailto:forums.jakob@resfarm.de> Gesendet: Freitag, 31. Januar 2020 18:16:51 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] Should you override #doesNotUnderstand: and #respondsTo: together?
Regarding canUnderstand:, maybe it's time for the third boolean called "it depends" or "maybe". ;-)
Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.demailto:Christoph.Thiede@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@lists.squeakfoundation.orgmailto:squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Tobias Pape <Das.Linux@gmx.demailto:Das.Linux@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@student.hpi.uni-potsdam.demailto:Christoph.Thiede@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
squeak-dev@lists.squeakfoundation.org