[Gambas-user] Struct with Array Field

Mayost Sharon sharon at 455.co.il
Sat Apr 8 22:04:15 CEST 2023


---------- Original Message -----------
From: T Lee Davidson <t.lee.davidson at gmail.com>
To: user at lists.gambas-basic.org
Sent: Fri, 7 Apr 2023 13:08:35 -0400
Subject: Re: [Gambas-user] Struct with Array Field

> On 4/6/23 17:45, Jussi Lahtinen wrote:
> > 
> >      > In c terms which structure are interface for, strings and arrays are just pointer that are not initialized to a value until
> >      > something is assigned to them.
> >      >
> >      > When you do a  mstrct = new mystruct it creates the structure with null pointers for those fields.
> > 
> [snip]
> > 
> > The topic was *objects *inside structure. They have only null pointers. Variables are valid without further actions.
> > C does not have "new", but he was referring to the similar things that need to be done in C.
> > 
> > Jussi
> 
> Yes, the original topic was arrays (objects) in a structure. To help clarify 
> for the OP, I gave examples of what did or did not need to be explicitly 
> initialized in a structure. Brian's response was to make a false statement 
> which, to help prevent confusion, needed to be corrected.
> 
> The statement, "When you do a  mstrct = new mystruct it creates the structure 
> with null pointers for those fields," does not refer to what happens in C. And,
>  "those fields," obviously refers to "strings and arrays". As I explained, the 
> strings would be automatically initialized, but the arrays would not.
> 
> Is there anything incorrect about the following statement?
> Simple native datatypes (such as String, Integer, Boolean) will be 
> automatically initialized. But, objects (such as String[], Integer[],
>  Boolean[]), which are objects of classes and have properties and methods, 
> must be initialized with the NEW keyword.
> 
> -- 
> Lee
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
------- End of Original Message -------

If I have a structure that contains many array variables, etc.
If I need to do NEW on every variable that is an array
Why do I need it inside the structure?
Is there a way in NEW once to execute on all variables?

Thanks


More information about the User mailing list