xsharp.eu • Calling convention methods, VO to X#
Page 1 of 1

Calling convention methods, VO to X#

Posted: Thu Jun 27, 2019 3:33 am
by wriedmann
Hello,
in VO, a strong typed method is declared like this:

Code: Select all

method MyMethod( cParam as string ) as void pascal class MyClass
If I understand correctly, in X# (VO dialect), the Pascal calling should not be used anymore.
So, if I define a method in X# as

Code: Select all

method MyMethod( cParam as string ) as void
this method uses the Clipper calling convention? But it seems to enforce the typed parameter and return type.
And I can also write

Code: Select all

method MyMethod( uParam ) as int strict
without typing the uParam parameter?
I have seen, that even VO lets me define a method as

Code: Select all

method MyMethod( uParam ) as int pascal class MyClass
My final question is: how I should type my methods in new X# code, VO dialect?
In VO it was easy: I have typed methods using "as pascal" whenever possible, and otherwise I have not typed them at all. But it seems there are several intermediate forms.
Thank you for any clarification
Wolfgang

Calling convention methods, VO to X#

Posted: Thu Jun 27, 2019 4:14 am
by Chris
Hi Wolfgang,

Normally (when you strongly type them) all methods in X# (also in vulcan) are STRICT/PASCAL, which is the same thing. They become CLIPPER calling convention when you do not specify their parameter types, so this is a CLIPPER cc method:

METHOD Test(a,b,c) // CLIPPER cc

Even when you specify a return type, if the parameters are untyped, then it also becomes CLIPPER cc:

METHOD Test(a,b,c) AS INT // CLIPPER cc

When a method has no parameters, like

METHOD Test() AS INT

then by default the compiler treats it as STRICT. That is, unless you enable the /vo5 (Implicit CLIPPER calling convention) compiler option, in which case such methods become CLIPPER (for compatibility with VO).

For such methods (which are not clear to the compiler what cc you intended to use), you can use the CLIPPER/STRICT clauses to instruct the compiler what cc to use, overriding the /vo5 options:

METHOD Test() AS INT CLIPPER
METHOD Test() AS INT STRICT

Apart from this case, I cannot think of any other case where you might want to specifically supply the CLIPPER/STRICT clause to your methods.

Calling convention methods, VO to X#

Posted: Thu Jun 27, 2019 9:40 am
by wriedmann
Hi Chris,

thank you very much for this clarification!

Wolfgang