[Gambas-user] structure and class

Marco Ancillotti gambas at servinfo.it
Tue Aug 8 11:53:43 CEST 2023


Hi BB

I need to create the class at runtime , I don't know the variable in the 
class needed before I run some code.
Is there a way to create a new class type and add variables to it by code ?

thanks,
marco.

Il 08/08/23 11:31, BB ha scritto:
>
> 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
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----




More information about the User mailing list