Override in inheritance chain

Writing and using Classes in Dyalog APL

Override in inheritance chain

Postby zaibot.w on Fri Apr 16, 2021 7:25 pm

Hi,

I have experienced some very unexpected and annoying behavior when dealing with an inheritance chain and a method that is supposed to be override in both subclasses. Here is a simple example:

Code: Select all
:class BC

∇ sayHello
  :access public overridable
  'I'm the base class.'


∇ speak
  :access public
  sayHello


:endclass


:class SC1 : BC

∇ sayHello
  :access public override
  'I'm the first subclass.'


:endclass


:class SC2 : SC1

∇ sayHello
  :access public override
  'I'm the second subclass.'


:endclass



Code: Select all
inst←⎕new SC2
inst.speak
⍝ inst says "I'm the first subclass."
⍝ Intuitively, I would expect "I'm the second subclass.", which is also what you would get in other programming languages.


Even if I additionally mark
Code: Select all
sayHello
as overridable in SC1 so that it is marked as override AND overridable at the same time (which is possible), I get the same behavior.

Is this intended?
zaibot.w
 
Posts: 3
Joined: Mon Jun 29, 2020 4:09 pm

Re: Override in inheritance chain

Postby Vince|Dyalog on Tue Apr 20, 2021 3:50 pm

Hi zaibot.w,

I think this may be a bug, so I will add your example to this issue:

7625: Multiple levels of the class keyword Override do not work.

Regards,

Vince
Vince|Dyalog
 
Posts: 348
Joined: Wed Oct 01, 2008 9:39 am


Return to Object Oriented Programming

Who is online

Users browsing this forum: No registered users and 1 guest