FoxPro syntax, Properties and fields

This forum is meant for questions about the Visual FoxPro Language support in X#.

mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro syntax, Properties and fields

Post by mainhatten »

Robert,
Johan Nel wrote:Hi Robert,
robert wrote:Antonio
Do you know if there is an overview somewhere of the different bases classes , or better of the complete class hierarchy ?
Is THIS what you looking for?
bit swamped at the moment, but latest on weekend I can build a table with all vfp language elements, which also might be used as a simple test bed for xSharp runtime. I built that for testing Lianja, but when Lianja scrapped the embedded server for mobile clients we dropped participation. Code was in Lianja on company machine where I worked back then - doubt I have it locally, but perhaps Hank still has parts and sends them, or I will recreate it again, unless you already have such a table

regards

thomas
User avatar
Jáder E. Souza
Posts: 3
Joined: Thu Aug 08, 2019 11:15 am

FoxPro syntax, Properties and fields

Post by Jáder E. Souza »

Regarding treating as fields or properties, take a look at Acces and Assign methods:

Visual FoxPro supports Access and Assign methods, which are user-defined procedures or functions that have the same name as a class property and have the suffix _ACCESS or _ASSIGN appended to the procedure or function name. You can use Access and Assign methods to execute code when querying the value of a property or attempting to change the property's value. Visual FoxPro executes Access and Assign methods only when querying or changing property values at run time, not design time. You can create Access and Assign methods separately and independently of each other.

Access and Assign methods provide the following benefits:

You can create a public interface for a class or object that separates the interface from the implementation.

You can easily implement property validation.

You can easily protect properties in subclassed ActiveX controls.

Visual FoxPro executes code in an Access method when querying the value of a property, typically by using the property in an object reference, storing the property value to a variable, or displaying the property value with the question mark (?) command.

Visual FoxPro executes code in an Assign method when you attempt to change the property value, typically by using the STORE command or = operator to assign a new value to the property.
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro syntax, Properties and fields

Post by robert »

Jader,
This is exactly what the X# compiler does with the _ACCESS and _ASSIGN methods. _ACCESS becomes a Property Gettter and _ASSIGN a Property Setter.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

FoxPro syntax, Properties and fields

Post by lumberjack »

Good day Jader,
Jáder E. Souza wrote:Regarding treating as fields or properties, take a look at Acces and Assign methods:
X# will support this in the 2.08 release. The implementation does however allow you not to have to declare a "Field" for the _ACCESS/_ASSIGN. The standard implementation in X# is PROPERTY...GET...SET...END PROPERTY:

Code: Select all

CLASS Person
  PROTECT _fname, _lname AS STRING
  PROPERTY FirstName AS STRING
    GET
      RETURN _fname
    END GET
    SET
      _fname := VALUE
    END SET
  END PROPERTY
  PROPERTY LastName AS STRING GET RETURN _lname SET _lname := VALUE // Short version
  PROPERTY FullName AS STRING GET RETURN _fname + _lname && No assign/set readonly
END CLASS
Regards,
______________________
Johan Nel
Boshof, South Africa
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro syntax, Properties and fields

Post by robert »

Johan,

This is the 'normal' class syntax
I have also added fields for the VFP syntax
If you prefix the list of property names with the FIELD keyword then fields will be created instead of properties

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro syntax, Properties and fields

Post by mainhatten »

Robert van der Hulst wrote: 5) Now that we move FoxPro to .Net we will also be able add new functionality. So far we have added the following (for free because it is there in our compiler already)
- The ability to declare attributes on a type, property method etc
- The ability to add more (visibility) modifiers then just PROTECTED and HIDDEN. For example also INTERNAL,ABSTRACT, STATIC and SEALED
- The ability to define Generic types and methods

Code: Select all

DEFINE CLASS MyStack<T> WHERE T IS NEW()
- All types can be specified in the Namespace.Type syntax. For example

Code: Select all

CLASS MyTable as System.Data.DataTable
I have more questions but these can be handled later
I would value your input on this.
Vfp as a language, while prototypal, is even stricter in enforcing single inheritance than newer versions of "mostly single inheritance" languages with interfaces sans default methods like Java a few years ago and C# up until now. I have not looked in detail at C#8 implementing default methods in interfaces, but liked the feature when introduce in Java. Having a syntax supporting this and adding such interfaces to existing single inheritance vfp code would be a real benefit from my POV.
If this is easy to implement, might interest those already yearning for MIXIN-type OOP often found in other dynamic kanguages like Python or Javascript.
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

FoxPro syntax, Properties and fields

Post by lumberjack »

Hi Thomas,
Thomas Ganss wrote:Vfp as a language, while prototypal, is even stricter in enforcing single inheritance than newer versions of "mostly single inheritance" languages with interfaces sans default methods like Java a few years ago and C# up until now. I have not looked in detail at C#8 implementing default methods in interfaces, but liked the feature when introduce in Java. Having a syntax supporting this and adding such interfaces to existing single inheritance vfp code would be a real benefit from my POV.
If this is easy to implement, might interest those already yearning for MIXIN-type OOP often found in other dynamic languages like Python or Javascript.
Well have not tested with the VFP syntax, but you can in X# core already have interfaces:

Code: Select all

CLASS MyClass INHERIT Foo IMPLEMENTS IFoo1, IFoo2, IFoo3
  // And overloaded methods
  CONSTRUCTOR()
  RETURN
  CONSTRUCTOR(i AS INT)
  RETURN
  CONSTRUCTOR(s AS STRING)
  RETURN
END CLASS
______________________
Johan Nel
Boshof, South Africa
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro syntax, Properties and fields

Post by mainhatten »

Johan Nel wrote:Hi
Well have not tested with the VFP syntax, but you can in X# core already have interfaces:

Code: Select all

CLASS MyClass INHERIT Foo IMPLEMENTS IFoo1, IFoo2, IFoo3
  // And overloaded methods
  CONSTRUCTOR()
  RETURN
  CONSTRUCTOR(i AS INT)
  RETURN
  CONSTRUCTOR(s AS STRING)
  RETURN
END CLASS
Hi Johan,

In regular vfp we have in the corresponding define class command the clause

Code: Select all

   [IMPLEMENTS cInterfaceName [EXCLUDE] IN TypeLib | TypeLibGUID | ProgID ]
which is used when attaching to the events and methods of a COM object.
Attaching to COM should still be supported for all those automating Word or Excel. Due to COM rules any method/event has to be explicitly coded, which at least for C#8 IL has been eliminated.
If the compiler can keep "Implements" while pointing to DotNet-interfaces all the better - but not the main point.
Vfp has no command to define a new interface, this is mangled in with the definition of COM objects
[/code]
DEFINE CLASS myOLEClass AS Custom OLEPUBLIC
MyProperty = 5.2
* Set COM attributes for MyProperty.
DIMENSION MyProperty_COMATTRIB[4]
myProperty_COMATTRIB[1] = COMATTRIB_READONLY
myProperty_COMATTRIB[2] = "Help text displayed in object browser"
myProperty_COMATTRIB[3] = "MyProperty" && Proper capitalization.
myProperty_COMATTRIB[4] = "Float" && Data type
ENDDEFINE[/code]

so for Dotnet/IL interfaces I would hope for something more succinct that compiles down to

Code: Select all

public interface IxSharpCoreOrVfp
which would add multi-inheritance to xSharp with no further effort. No idea if rest of vfp devs miss such options - I have no product I continously maintain, but work on projects, where I see in other languages benefits of shallow inheritance hierarchy coupled with some mixin tweaks.
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

FoxPro syntax, Properties and fields

Post by lumberjack »

Hi Thomas,
Thomas Ganss wrote: In regular vfp we have in the corresponding define class command the clause

Code: Select all

   [IMPLEMENTS cInterfaceName [EXCLUDE] IN TypeLib | TypeLibGUID | ProgID ]
which is used when attaching to the events and methods of a COM object.
Attaching to COM should still be supported for all those automating Word or Excel. Due to COM rules any method/event has to be explicitly coded, which at least for C#8 IL has been eliminated.
If the compiler can keep "Implements" while pointing to DotNet-interfaces all the better - but not the main point.
Vfp has no command to define a new interface, this is mangled in with the definition of COM objects

Code: Select all

DEFINE CLASS myOLEClass AS Custom OLEPUBLIC
   MyProperty = 5.2
   * Set COM attributes for MyProperty.
   DIMENSION MyProperty_COMATTRIB[4]
   myProperty_COMATTRIB[1] = COMATTRIB_READONLY
   myProperty_COMATTRIB[2] = "Help text displayed in object browser"
   myProperty_COMATTRIB[3] = "MyProperty"  && Proper capitalization.
   myProperty_COMATTRIB[4] = "Float"        && Data type
ENDDEFINE
so for Dotnet/IL interfaces I would hope for something more succinct that compiles down to

Code: Select all

public interface IxSharpCoreOrVfp
which would add multi-inheritance to xSharp with no further effort. No idea if rest of vfp devs miss such options - I have no product I continously maintain, but work on projects, where I see in other languages benefits of shallow inheritance hierarchy coupled with some mixin tweaks.
Yes X# already allow you to create interfaces:

Code: Select all

[Attributes] [Modifiers] INTERFACE <idInterface> [INHERIT <idInterface>] 
 [InterfaceMembers]
 END INTERFACE
______________________
Johan Nel
Boshof, South Africa
mainhatten
Posts: 200
Joined: Wed Oct 09, 2019 6:51 pm

FoxPro syntax, Properties and fields

Post by mainhatten »

Yes X# already allow you to create interfaces:

Code: Select all

[Attributes] [Modifiers] INTERFACE <idInterface> [INHERIT <idInterface>] 
 [InterfaceMembers]
 END INTERFACE
Looks perfectly understandable. Make a small example for SWFox, but decide on the fly if you show in depth the new MI options or if it is better just to tell grizzled veterans, that now they can tempt young coders with newest techniques from Redmond - not only asynch..await but safe multiple inheritance as well

Tailor the show to the audience...
Post Reply