On Wed, 15 Feb 2017, Gianluigi wrote: > Hi Fabien, > let's see if I can clarify this. > In Gambas there are three different types of class: > - The real Class and its to be instantiated through the constructor (_new). > - The Form which is a class already instantiated, but can receive the > parameters which exposes the constructor (_new). > - The Module is a class already instantiated, and that does not expose the > constructor. > > Therefore I can refer to a module with Me, I can use inside events and I > can even assign _new with another name to the module even if do not really > need. > I'm on the right track? >
This is not how I would understand the matter. First of all, you have your normal classes in Gambas. You can alter their behaviour by setting certain "flags" in your class. These flags are actually keywords in the Gambas language and you have to specify them at the beginning of your class file at compile time. o CREATE PRIVATE tells the interpreter that the current class is not instanciable. o CREATE STATIC tells the interpreter to create an automatic instance of the class which is used automatically when you use the class name like an object. There is also EXPORT and INHERITS, but they're of minor relevance for the topic at hand. None of these flags influence the presence of ME or events. They are always available. Now, a module is a normal class in which every symbol is implicitly made static by the compiler. You can still create objects from a module but that isn't useful because you don't have dynamic symbols in a module. You will just end up with multiple objects that all reference the same data. The only way the Form class is any special is because it has dedicated support for .form files in the compiler. Other than that it is a normal class -- which uses the CREATE STATIC flag. Quoting the definition of the Form class from gb.qt4/src/CWindow.cpp: 1466 GB_DESC CFormDesc[] = 1467 { 1468 GB_DECLARE("Form", sizeof(CFORM)), GB_INHERITS("Window"), 1469 GB_AUTO_CREATABLE(), 1470 1471 GB_STATIC_METHOD("Main", NULL, CFORM_main, NULL), 1472 GB_STATIC_METHOD("Load", NULL, CFORM_load, "[(Parent)Control;]"), 1473 GB_METHOD("_new", NULL, CFORM_new, NULL), 1474 1475 FORM_DESCRIPTION, 1476 1477 GB_END_DECLARE 1478 }; The macro GB_AUTO_CREATABLE() is the C rendition of CREATE STATIC. As you can see, Form just inherits Window and adds three further methods. These methods are actually what makes Form classes behave the special way they do, like automatically showing on program startup and being their own event observers. (And, well, there's the FORM_DESCRIPTION macro but don't worry about it.) My point is, the behaviour of a Form is accomplished by standard Gambas mechanisms, that are available to everyone (only the conversion of .form files to executable code needs specific support in the compiler). Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user