[Gambas-user] Structure support in Gambas 3

EA7DFH ea7dfh at ...2382...
Thu May 27 21:08:21 CEST 2010


El 27/05/10 00:51, Benoît Minisini escribió:
> Hi,
> 
> I have just committed a new big internal change for Gambas 3 in revision 
> #2970: structure support.
> 
> It is not 100% finished, must most of the useful parts are there. If that 
> crashes your program - I will be amazed if it won't :-) - you know where to 
> knock.
> 
> How does it work?
> 
> To define a structure, you must declare it inside a class or a module that 
> way:
> 
> 	Public Struct <StructName>
> 	  <Var1> As <Type1>
> 	  <Var2> As <Type2>
> 	End Struct
> 
> A structure is always public (at the moment).
> 
> A structure is a class, with only public members that are actually variables.
> 
> You can embed a structure inside an object that way:
> 
> 	Private <ClassVariable> As Struct <StructName>
> 
> Note the 'Struct' keyword inserted before <StructName>.
> 
> An embedded structure is not an object on its own. Its data is allocated 
> inside the object where it is declared. Like a "static array" (that should be 
> named "embedded array" actually). Note that you cannot make an "embedded 
> array" of static structures.
> 
> You can embed a structure inside another structure (logical, as a structure is 
> a class). That way, you can create russian dolls if you like. Here is a stupid 
> example:
> 
> 	Public Struct Car
> 		Model As String
> 		Registration As String
> 		MaxSpeed As Float
> 	End Struct
> 
> 	Public Struct Person
> 		Name As String
> 		Age As Integer
> 		BirthDate As Date
> 		FirstCar As Struct Car
> 		SecondCar As Struct Car
> 	End Struct

> Enjoy it.
> 

Hi

Thanks for this new amazing feature.

I've noted that while writing code, autocompleter still isn't able to
manage/display Struct members. Is it planned to do so?

Everything else works as expected so far, although I didn't tested it
deeply.

Regards
-- 
Jesus, EA7DFH




More information about the User mailing list