Thanks Benoît, i understood the array subject well.

But one note.

i cant do in Gambas2-2.21
PUBLIC aInt2[10] AS Integer 
in declaration section of a class

so the syntax
[Static] {Private|Public} EmbeddedArray[A, B] As Type

is it correct, for the Public keyword?


On Tue, 2010-11-23 at 19:13 +0100, Benoît Minisini wrote:
> Hi,
> 
> This is a clarification about Gambas arrays for Demosthene and all who 
> answered him.
> 
> There are two kinds of arrays in Gambas:
> - "Normal" arrays.
> - "Embedded" arrays.
> 
> Fabien used the word "static" arrays for "embedded" arrays because this was 
> the word I used first. Then I changed to "embedded" to avoid any confusion 
> with the "STATIC" keywords, which is not related at all.
> 
> "Normal" arrays are true Gambas objects. They have their own memory 
> allocation, and they are destroyed when they are not referenced anymore.
> 
> To declare a "normal" array, you can do:
> 
>       (1) Dim NormalArray As Type[]
>       (2) Dim NormalArray As Type[] = [ ... ]
>       (3) Dim NormalArray As Type[] = New Type[A, B]
>       (4) Dim NormalArray As Type[A, B]
> 
> (1) declares an object variable that can receive a reference to a array whose 
> type is "Type[]". "Type" can be a native datatype or a class name. Note that 
> in Gambas 2, "Type" can only be a native datatype.
> 
> (2) declares an object variable, and initializes it with a new array created 
> by the [ ... ] operator.
> 
> (3) declares an object variable, and initializes it with a new array hainvg 
> the specified dimension.
> 
> (4) is a shortcut to the (3) syntax.
> 
> "Embedded" arrays are arrays that are allocated *inside* another object. They 
> don't have a memory allocation on their own, and they are automatically freed 
> with the object including them.
> 
> "Embedded" arrays are always member of a class or a structure only.
> 
> To declare an "embedded" array, you do the following:
> 
>       [Static] {Private|Public} EmbeddedArray[A, B] As Type
> 
> There, "Type" is the datatype of one element of the array. There is no "[]" 
> after the type, unless you want to store array references inside the array of 
> course.
> 
> "Embedded" arrays can be static or not, public or private.
> 
> "Embedded" arrays are a little bit slower than normal arrays.
> 
> They were created to mimic C arrays (like Gambas structures, that were 
> created 
> to mimic C structures), so that working with extern C functions using arrays 
> and structures is possible. 
> 
> So you should not use them, unless you are working with extern functions.
> 
> I hope Gambas arrays are clearer now!
> 
> Regards,
> 

-- 
Regards,
Demosthenes


------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to