[Gambas-user] structure and class
adamnt42 at gmail.com
Tue Aug 8 12:46:09 CEST 2023
On 8/8/23 7:23 pm, Marco Ancillotti wrote:
> 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 ?
> 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,
>> 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.
Wow! I love your thinking here. Let me paraphrase it as I see it.
Someone hands you a bag. You put your unprotected arm in the bag and try
and determine the attributes of the contents. "Hmm, it's scaley and it
bites." or "Hmm, its soft and squeezy and has point on the end."
To be serious, I think we might need to know a bit more about the "some
code" that you are running before you put your arm in, so to speak.
To be really serious, I think I have a similar problem that I have not
found an answer to. I have an unstructured text file that I need to
break up into "paragraphs". The structure is totally in-determinant.
"I" can see the structure but I'll be damned if I can see a way to break
Keep me updated!
More information about the User