Calling convention methods, VO to X#

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Calling convention methods, VO to X#

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Calling convention methods, VO to X#

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Calling convention methods, VO to X#

Post by wriedmann »

Hi Chris,

thank you very much for this clarification!

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply