Class implementation ...
-
- Posts: 237
- Joined: Jul 15, 2021 7:23
- Location: Greece
- Contact:
Class implementation ...
Hello,
i read the wiki help chm about constructors and destructors and i see the keyword CLASS which is not implemented yet.
When do you plan to implement CLASS keyword? It would be great improvement to use it instead TYPE.
i read the wiki help chm about constructors and destructors and i see the keyword CLASS which is not implemented yet.
When do you plan to implement CLASS keyword? It would be great improvement to use it instead TYPE.
Re: Class implementation ...
Welcome to the forum!
At first glance, a CLASS would only 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).
- Other features ???
That being said, I would rather be in favor of implementing the INTERFACE structure first, which would provide new and more useful functionality.
At first glance, a CLASS would only 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).
- Other features ???
That being said, I would rather be in favor of implementing the INTERFACE structure first, which would provide new and more useful functionality.
-
- Posts: 606
- Joined: Nov 28, 2012 1:27
- Location: CA, USA moving to WA, USA
- Contact:
Re: Class implementation ...
While there are many features of the CLASS concept that are not yet present automatically, one can pretend that a udt TYPE is a class.
Just add the qualities that you desire.
For example, you can add your own RTTI or RAII as you wish.
The flexibility is present in FreeBASIC.
Just add the qualities that you desire.
For example, you can add your own RTTI or RAII as you wish.
The flexibility is present in FreeBASIC.
Re: Class implementation ...
What great improvement would that be? FB's TYPE is nearly exactly equivalent to C++'s class. There's really no need for a "CLASS" keyword to clutter up the namespace. TYPE already does what you want. I'm really not completely sure why C++ chose to add "class" instead of just adding syntax and public/protected/private to struct. I assume it had something to do with C++ at the time being a pre-processor for C. In any case, FB has no such encumbrances.demosthenesk wrote:When do you plan to implement CLASS keyword? It would be great improvement to use it instead TYPE.
Re: Class implementation ...
The "class" keyword is a quasi-reserved word in the fbc compiler (it's a token word) and reserved for future use in the documentation: see Classcaseih wrote:demosthenesk wrote:FB's TYPE is nearly exactly equivalent to C++'s class. There's really no need for a "CLASS" keyword to clutter up the namespace.
I agree that "type" and "class" will have similar end results in terms of the binary code emitted.
To be honest, I'm not sure what "class" has in store for us, but I would suspect that it will allow member definitions to be nested within the "class" structure itself. Maybe in fbc version 2. To allow member definitions to be specified within the class delcaration/definition would require a different machinery within the fbc compiler to allow it. Currently, "type" declarations must be complete followed by the implementation (definition of members) separately.
Re: Class implementation ...
Yes, that makes sense.
Re: Class implementation ...
If I understood correctly, as long as those implementations are defined as "private" they will behave just as if they were defined inside the class, right?coderJeff wrote:Currently, "type" declarations must be complete followed by the implementation (definition of members) separately.
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Class implementation ...
In WIndows COM programming, classes are important because they allow to develop an object with multiple interfaces. With Type, you can only have one interface.
Re: Class implementation ...
I think C++ allows member function to be implemented inside the class structure so they are automatically inlined.
I think templates would be a nice addition to fb
Even freepascal has them now (generics)
{$mode delphi}
procedure something<T>(var arr:array of T);
...
...
something<integer>(I);
something<string>(s);
Using macros is a bit outdated IMO.
Cannot multiple interfaces be implemented via virtual functions in various extended types and an abstract function in the (base) type?
I think templates would be a nice addition to fb
Even freepascal has them now (generics)
{$mode delphi}
procedure something<T>(var arr:array of T);
...
...
something<integer>(I);
something<string>(s);
Using macros is a bit outdated IMO.
Cannot multiple interfaces be implemented via virtual functions in various extended types and an abstract function in the (base) type?
Re: Class implementation ...
Sure but COM isn't a programming language. You can use it from a straight C interface if you want. I can see that it might make it more convenient if the programming language has syntax that makes COM easy.Josep Roca wrote:In WIndows COM programming, classes are important because they allow to develop an object with multiple interfaces. With Type, you can only have one interface.
Re: Class implementation ...
As far as I know, language D, too, offers only single inheritance, and still it is pretty compatible with C++. Right now I have the impression FreeBasic is more or less at the same level of D, in that regard
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Class implementation ...
> Sure but COM isn't a programming language. You can use it from a straight C interface if you want. I can see that it might make it more
> convenient if the programming language has syntax that makes COM easy.
I can use COM with any language that supports pointers and structures, but writing COM servers without native support for classes and interfaces is too cumbersome.
> convenient if the programming language has syntax that makes COM easy.
I can use COM with any language that supports pointers and structures, but writing COM servers without native support for classes and interfaces is too cumbersome.