Re: [Vala] array declaration



My opinion matter not, but it makes more sense to me to force the ' type[]
name = new type[] ' syntax.
Not only does it make more phonetic sense, but it also eliminates ambiguity
when using the 'var name = new type[]'  syntax. (If the other syntax were
allowed, would var name[] = new type[] be correct or would var name = new
type[] be correct?).


Seth Hoenig
seth a hoenig gmail com




On Wed, Jul 7, 2010 at 11:33 AM, Harry Van Haaren <harryhaaren gmail com>wrote:

Hey,

Coming from a C++ background I first tried   typeHere  nameHere[];  too.
I noticed that newer languages seemed to have   type[]  name; configuration
(Java, C# etc).

I'm not part of the Vala team though, so I dont know the "official" status!
-Harry

On Wed, Jul 7, 2010 at 5:15 PM, pancake <pancake youterm com> wrote:

 I have noticed that if you declare an array in a wrong way you get
errors
from the C compiler
instead of handling it at vala level.

should this syntax be supported? or we should just throw an error?

Here's the test case:

$ cat a.vala
#!/usr/bin/vala
void main () {
       // uint8[] foo = new uint8[16]; // OK
       uint8 foo[] = new uint8[16]; // FAIL
       print("%d\n", foo[0]);
}

$ vala a.vala
/tmp/a.vala.LDAGFV.c: In function '_vala_main':
/tmp/a.vala.LDAGFV.c:16:9: error: array size missing in '_tmp0_'
/tmp/a.vala.LDAGFV.c:19:9: error: array size missing in 'foo'
/tmp/a.vala.LDAGFV.c:20:16: error: incompatible types when assigning to
type 'guint8[1]' from type 'guint8 *'
/tmp/a.vala.LDAGFV.c:20:6: error: incompatible types when assigning to
type
'guint8[1]' from type 'guint8 *'
/tmp/a.vala.LDAGFV.c:22:6: error: incompatible types when assigning to
type
'guint8[1]' from type 'void *'
error: cc exited with status 256


Thanks

--pancake
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list


_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]