Implement Interface Using Super
Meta
jared771 at gmail.com
Wed Jan 30 02:54:45 UTC 2019
On Wednesday, 30 January 2019 at 01:02:37 UTC, Jonathan M Davis
wrote:
> Yeah. It would be like trying to do something like
>
> alias x = this.x;
>
> As it stands, I believe that super is always either used as a
> function call to the constructor or to mean the this pointer
> for the base class. I don't think that it ever means the type
> of the base class - just like this never means the type of the
> current class or struct. And their usage is pretty much
> identical. They're both either used for calling a constructor
> or for accessing the pointer/reference of the object. It's just
> that one of them is for the current class or struct, whereas
> the other is for a base class of the current class. The only
> difference in syntax that I can think of between them at the
> moment is that this is also used to name constructors when
> they're declared, whereas super is not used in that sort of way
> (since any constructor that would be referenced by super would
> be declared with this, not super).
>
> - Jonathan M Davis
Current, you *can* use `super` to mean the type of the base
class, but it's been deprecated in a recent release (IIRC):
class Super
{
}
class Sub
{
super test()
{
return new Super();
}
}
void main()
{
(new Sub()).test();
}
From DPaste:
Up to 2.080.1: Success and no output
Since 2.081.2: Success with output: onlineapp.d(7):
Deprecation: Using `super` as a type is deprecated. Use
`typeof(super)` instead
More information about the Digitalmars-d-learn
mailing list