[Gambas-user] structure and class

BB adamnt42 at gmail.com
Tue Aug 8 11:31:57 CEST 2023


On 8/8/23 6:19 pm, Marco Ancillotti wrote:
> Hi all,
>
> I have a working program that use a class that have only variables.
>
> Now I need do dynamic declare the class , is there a way to do so ?
>
> I can use structure but I learn that in gambas a structure is simply a 
> class with only variables and the
> help say it's slow. is there another way to do it or I need to use 
> structure ?
>
> thanks in advance,
> Marco.
>
I am not sure what you mean by "dynamic declare a class". Could you 
perhaps explain.

The following is opinion only. The only time I use structs is to cope 
with externs or when I need a quick structured variable that will never 
have cause to have any method added. Whether they are "slow" or not I 
don't know, I've never noticed anything. However, I have usually found 
as the project develops that a complex "data only" class eventually 
results in the addition of some handy methods, whether or not I have 
seen a need for them at the outset. The only other place I can recall 
where I have used structs is to create a typed array, in a quick and 
ugly manner (and it creates poor code structure) but can be effective. 
On further thought, I seem to recall that I have ended up re-coding the 
thing as a class.

best

b



More information about the User mailing list