I was curious what was the future intention for the 'Class' keyword? Right now FB recognizes it as a reserved keyword, but I don't see any use for it currently. Would it make sense to treat it similar to Type? I was just curious what features it would have beyond what Type offers.
Cheers
-Vince
'Class' Keyword
Re: 'Class' Keyword
This is just my personal opinion (no echo from Jeff):
fxm wrote: ↑Feb 14, 2022 16:39I think what is missing next is the INTERFACE structure (new structure for FB) which the new CLASS keyword should also be able to support (implement).exagonx wrote: ↑Feb 14, 2022 16:01Forgive me if you are not well prepared on the subject (even if I actually consider myself ignorant) but I did not understand what the FreeBASIC TYPE lacks to be a full-fledged Class.fxm wrote: ↑Feb 13, 2022 17:16
A class would just be a particularization of a TYPE with default features:
- Implicitly extending OBJECT (from the base CLASS).
- Implicitly all non-static member procedures being VIRTUAL (or ABSTRACT if no procedure body is defined).
- Implicitly having a default virtual destructor (for full compatibility with polymorphism).
- others??? (member fields protected by default)
The CLASS keyword is already reserved, so why not implement it now like that?
The IMPLEMENTS keyword is already reserved but not INTERFACE.
Re: 'Class' Keyword
I think support for Interfaces would be outstanding but would also require compatibility with Is and TypeOf and probably others. I have really become accustomed to the Class/Interface pattern and find it a great method for organizing functionality.
Cheers
-Vince
Re: 'Class' Keyword
From TODO.txt
- what should CLASS keyword do? struct vs. class as in C++?
And from wiki
- Declares a class object
The CLASS keyword was reserved long ago only with the idea that we want to do something with it, but is currently future unknown.
My opinions:
- CLASS should not be some simple variant of TYPE
- TYPE is a kind of low-level construction with heavy ties to gcc/g++ (when exported), and can be either trivial (i.e. a memory layout) or complex (methods, vtables, etc)
- CLASS could be used to break away from some gcc/g++ restrictions and let fbc do it's own thing
- CLASS could be used to break away from current single pass compiler requirements - implementation within fbc would be more complex, but should make it easier for users to write code with method definitions within the class body, easier use for classes that refer to each other and avoid complicated forward referencing for users (and type patching within fbc), etc.
- what should CLASS keyword do? struct vs. class as in C++?
And from wiki
- Declares a class object
The CLASS keyword was reserved long ago only with the idea that we want to do something with it, but is currently future unknown.
My opinions:
- CLASS should not be some simple variant of TYPE
- TYPE is a kind of low-level construction with heavy ties to gcc/g++ (when exported), and can be either trivial (i.e. a memory layout) or complex (methods, vtables, etc)
- CLASS could be used to break away from some gcc/g++ restrictions and let fbc do it's own thing
- CLASS could be used to break away from current single pass compiler requirements - implementation within fbc would be more complex, but should make it easier for users to write code with method definitions within the class body, easier use for classes that refer to each other and avoid complicated forward referencing for users (and type patching within fbc), etc.