1) In FoxPro all classes (have to) inherit from a base class. The ultimate base class is Custom. This is not just an empty class, because it also provides quite a few properties, events and methods. For example properties like name, left, right, Events like Init, Error and Destroy and methods like AddObject, AddProperty etc.
What do you think, should we allow classes (declared with the FoxPro class definition syntax) to inherit from 'nothing' (i.o.w. from System.Object), which also means that these objects will only have the normal .Net methods such as GetType() GetHashCode() and ToString().
We could also add a compiler option that determines that when no base class is defined your class either inherits from System.Object or from XSharp.FoxPro.Custom.
2) The FoxPro class syntax speaks of "Properties" and not of "Fields" or "Instance variables"
Code: Select all
DEFINE CLASS ClassName1 AS ParentClass
[[PROTECTED | HIDDEN] PropertyName1, PropertyName2 ...]
[[.]Object.]PropertyName = eExpression ...]
The problem with compiling it to a field is that we sometimes see a syntax like this:
Code: Select all
DEFINE CLASS Animal as custom
Species = "Animal"
ENDDEFINE
DEFINE CLASS Dog AS Animal
Species = "Dog"
ENDDEFINE
Our compiler will then produce the warning:
Code: Select all
warning XS0108: 'Dog.Species' hides inherited member 'Animal.Species'. Use the new keyword if hiding was intended.
So my current thinking is to generate .Net properties from this and make these virtual so they can be overwritten in a child class. We can also add a collection, but we can also create a backing field. In case of a property that overrides a parent property we can change the getter and setter and redirect the call to the parent property.
But that would mean that you can't create fields with the current FoxPro syntax.
I see a couple of solutions:
a) with a special compiler option you can tell the compiler to generate fields or properties. When you generate fields you will get a warning when you redefine a field in subclass
b) we always generate properties but add a special syntax to declare fields, something like
Code: Select all
DEFINE CLASS ClassName1 AS ParentClass
[[PROTECTED | HIDDEN] FIELD Field1, Field2 ...]
FIELD FieldName = eExpression ...]
Code: Select all
[[PROTECTED | HIDDEN] PropertyName1, PropertyName2 ...] [AS DataType]
4) The ADD OBJECT syntax creates a property (field?) and sets the value of the property to a new object of the specified type and allows to set initial values for some properties of this new object. What is not clear to me is if this object is also automatically added to a collection of children (controls) in the class ?
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()
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.
Robert