xsharp.eu • Interface - "Implements or Inherit", to make a new comparer class - Page 2
Page 2 of 2

Interface - "Implements or Inherit", to make a new comparer class

Posted: Tue Jan 03, 2017 5:59 pm
by Phil Hepburn
Hi Frank,

Before we discuss the syntax of how we would like things, it is the 'meaning' that we must get right.

If we don't get Polymorphism correct then we are doomed. The Implements / Inherit issue was becoming a 'can't type' that issue! Before we define our syntax to exclude 'this or that', we do need to know what MUST be done to get the Polymorphism right.

Having said all that I don't consider myself knowledgeable at all in this field, so I warn others, and then stand aside ;-0)

For my 'feel' on this, I would say we just leave stuff as it is, until we see a problem to fix. Remember that I started this thread with two ways to do the same thing - both worked, and I ask for clarity. So to me this is not a reason to go and change 'stuff', with the possibility of breaking something.

How thinks you 'Batman' ?

Cheers,
Phil.
P.S. next big question, who is Batman ? Robert, Nikos or Chris ??

Interface - "Implements or Inherit", to make a new comparer class

Posted: Tue Jan 03, 2017 10:12 pm
by wriedmann
Hi Phil,

if I understand Robert correctly, you can write

Code: Select all

class MyClass inherit IMyInterface
or

Code: Select all

class MyClass implements IMyInterface
and the compiler generates exactly the same code - if IMyInterface is an interface, it used the "interface" meaning, and if IMyInterface would be a class, it would be use the "inherit" meaning.

I like X# explicite declaration of "implements" and "inherit" because it makes code easier to read, without thinking if a thing is a class (from which inherit) or an interface (which implement).

Personally, I would like a compiler error or warning if "implement" is used with a class or "inherit" is used with an interface.

Wolfgang

Interface - "Implements or Inherit", to make a new comparer class

Posted: Tue Jan 03, 2017 10:23 pm
by Phil Hepburn
Hi Wolfgang,

Okay' I go along with what you explain ;-0)

Seems good to me, and in-line with what I was thinking about.

Well done, clean and clear, and good common sense too I feel.

Are you still in the Yucatan ? Did you find the meteor ? Any signs of the odd dinosaur ? 

Hope your journey is a safe one if you still have to return home.

Regards,
Phil.

Interface - "Implements or Inherit", to make a new comparer class

Posted: Wed Jan 04, 2017 8:22 am
by Frank Maraite
Wolfgang, Phil,
Wolfgang Riedmann wrote: I like X# explicite declaration of "implements" and "inherit" because it makes code easier to read, without thinking if a thing is a class (from which inherit) or an interface (which implement).

Personally, I would like a compiler error or warning if "implement" is used with a class or "inherit" is used with an interface.

Wolfgang
that's right.

Indeed it is different:

- with inherting a class we inherit both an interface (all public members) and an, some times partially in case of abstract classes, implementation of this interface.
- otherwise we have to implement this interface completly.

So I would say together with the warning Wolfgang mentioned it would be perfect.

Frank

Interface - "Implements or Inherit", to make a new comparer class

Posted: Wed Jan 04, 2017 9:55 am
by robert
Wolfgang,
Wolfgang wrote: Personally, I would like a compiler error or warning if "implement" is used with a class or "inherit" is used with an interface.
I will see what I can do, but this does not have a high priority:
The translation from INHERIT and IMPLEMENTS to the ":" operator is done after the parsing stage when we transform the Antlr parse tree into a Roslyn parse tree. At that moment all we have is type names and no knowledge about whether these are classes or interfaces.
In a later compiler stage (the Binder) the compiler looks up the type names and then we can determine if the types are class or interface.

At that stage we could look back at the original Antlr parse tree and figure out if the type name was part of an INHERIT clause or part of an IMPLEMENTS clause and issue a warning.

We can probably implement this on a rainy Sunday afternoon, but right now we are chasing the last remaining issues in the VO/Vulcan compatibility.

Things like:

- The difference between LONG(p) and LONG(_CAST,p) for different types of p (PTR, BYTE PTR, VOSTRUCT PTR etc)
- The difference between PTR(p), PTR(u), PTR(_CAST,p) and PTR(_CAST,u) where p is a pointer and u a USUAL

I thought I understood this perfectly but Chris just found some cases where things are not what you would expect...

Robert

Interface - "Implements or Inherit", to make a new comparer class

Posted: Wed Jan 04, 2017 10:04 am
by Frank Maraite
Robert,
Robert van der Hulst wrote: We can probably implement this on a rainy Sunday afternoon, but right now we are chasing the last remaining issues in the VO/Vulcan compatibility.
I totally agree. It's kind of beauty, not a technical requirement.

Frank

Interface - "Implements or Inherit", to make a new comparer class

Posted: Wed Jan 04, 2017 11:13 am
by Phil Hepburn
I agree Robert and Frank,

keep this for when you have done the necessary stuff, there is plenty of that I should think ;-0)

At least we have as good as C#, so no need to panic.

You will have to wait a bit longer for your true 'beauty' Frank !

Speak soon,
Phil.
P.S. X# coding going well this morning - will post in Pearls later.

Interface - "Implements or Inherit", to make a new comparer class

Posted: Wed Jan 04, 2017 1:50 pm
by wriedmann
Hi Robert,

IMHO this syntax check has a very low priority - there are much more important things to do, even on a rainy day.

Wolfgang

@Phil: yes, I'm in Yucatan, today in Merida after visiting the pyramids in Uxmal yesterday. We have our return flight in the night from Saturday to Sunday