Re: [Gambas-user] About arrays

2010-11-24 Thread Demosthenes Koptsis
Good morning to all,

write this code to see something strange

DIM aInt2[1] AS String

PRINT IsObject(aInt2)

Gambas2-2.21 rev3300
Ubuntu 10.04, AMD64



--
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


Re: [Gambas-user] About arrays

2010-11-24 Thread Fabien Bodard
2010/11/24 Demosthenes Koptsis demosthen...@gmail.com:
 Good morning to all,

 write this code to see something strange

 DIM aInt2[1] AS String

 PRINT IsObject(aInt2)

 Gambas2-2.21 rev3300
 Ubuntu 10.04, AMD64

that ?

False

*** glibc detected *** menudyn: double free or corruption (fasttop):
0x0217beb0 ***


So isobject work correctly ... it is not an object ... it's an embedded array.

but for the rest ... yes it is not 'normal'

-- 
Fabien Bodard

--
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


Re: [Gambas-user] About arrays

2010-11-24 Thread Benoît Minisini
 Good morning to all,
 
 write this code to see something strange
 
 DIM aInt2[1] AS String
 
 PRINT IsObject(aInt2)
 
 Gambas2-2.21 rev3300
 Ubuntu 10.04, AMD64
 

I see nothing strange.

-- 
Benoît Minisini

--
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


Re: [Gambas-user] About arrays

2010-11-24 Thread Benoît Minisini
  Good morning to all,
  
  write this code to see something strange
  
  DIM aInt2[1] AS String
  
  PRINT IsObject(aInt2)
  
  Gambas2-2.21 rev3300
  Ubuntu 10.04, AMD64
 
 I see nothing strange.

Ah yes, I got the double free error.

-- 
Benoît Minisini

--
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


Re: [Gambas-user] About arrays

2010-11-24 Thread Benoît Minisini
   Good morning to all,
   
   write this code to see something strange
   
   DIM aInt2[1] AS String
   
   PRINT IsObject(aInt2)
   
   Gambas2-2.21 rev3300
   Ubuntu 10.04, AMD64
  
  I see nothing strange.
 
 Ah yes, I got the double free error.

Mmm. I'm not sure I will be able to fix that in Gambas 2.

Gambas 3 should be stronger against that, as embedded arrays are accessed 
through internal temporary objects (i.e. IsObject(EmbeddedArray) will return 
TRUE).

-- 
Benoît Minisini

--
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


Re: [Gambas-user] About arrays

2010-11-23 Thread Demosthenes Koptsis
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