xsharp.eu • Sendclass
Page 1 of 1

Sendclass

Posted: Tue Dec 17, 2019 10:22 am
by ecos
Hello,
the line

SendClass(SELF,#Setup,#DFSUBLister)

compiles without error, but the Method Setup of the Super-Super-Class DFSUBLister is not called.
What am I doing wrong

TIA
Karl

Sendclass

Posted: Tue Dec 17, 2019 10:49 am
by Karl-Heinz
Hi Karl,

don ´t you get an obsolete compiler warning ? When i search "Function SendClass" on Github the result is:

Code: Select all

/// <exclude/>
[ObsoleteAttribute( "'SendClass()' is not supported and always returns NIL")] ;
FUNCTION SendClass( o , symMethod , symClassName ) AS USUAL CLIPPER
	RETURN NIL

regards
Karl-Heinz

Sendclass

Posted: Tue Dec 17, 2019 10:55 am
by ecos
No warning...
So I have to find a workaround ?
I use this quite often in VO...

Sendclass

Posted: Tue Dec 17, 2019 11:22 am
by Chris
Hi Karl,

Maybe you have explicitly disabled showing that warning (it's number 618) in the project settings?

Any reason why you are using SendClass() instead of Send()? Send() does work fine. I will have another look, but I think it's not possible to implement the semantics of SendClass() in .Net.

Sendclass

Posted: Tue Dec 17, 2019 12:08 pm
by ecos
Hi Chris,
yes, warning 618 is disabled. Can't remeber to have done this...
What I do is certainly a bit ugly, but sometimes it makes sense in my code to skip the super:method and call super:super:method.
Is there any chance to do this ?

Sendclass

Posted: Tue Dec 17, 2019 12:18 pm
by Chris
Hi Karl,

There is a way, but is very complicated. Reflection (the mechanism used by Send() and late binding in general) can't do it, it's designed to always respect the inheritance rules. Only way I am aware of is to create dynamic IL code to do that, but this can be extremely difficult to implement correctly, especially if there are different method signatures involved.

Can you show some of your method declarations? Those that you may call with SendClass() I mean. If they are all standard untyped methods like usually done in VO, it will be a little easier to implement it. But if they are strongly typed, absolutely no way, sorry!

Sendclass

Posted: Tue Dec 17, 2019 12:29 pm
by ecos
Hi Chris,
then it makes definitely sense to review my VO-Code. I should certainly be able to find other solutions. Ages ago it seemed to be the easiest way and it worked for years. I'll be back, if I have severe problems with the changes...

Sendclass

Posted: Tue Dec 17, 2019 12:37 pm
by Chris
Hi Karl,

Yeah, a redesign in this particular area sounds like the best solution. If it turns out too be too difficult as well, maybe just give a sample of your methods and we'll have a look if it is possible to create a custom solution for those cases. But, yeah, a general all around solution is way to complicated unfortunately.

Sendclass

Posted: Tue Dec 17, 2019 2:04 pm
by robert
Karl,

The SendClass() function is marked with an Obsolete attribute. You should have a warning that this function is Obsolete.
Maybe you did not look at the compiler warnings ?

Robert

Sendclass

Posted: Tue Dec 17, 2019 2:26 pm
by ecos
Warning 618 was disabled. I have now enabled it and a lot of work...