All right , they might "behave like" pointers, but they are not mere
pointers, cf:


///
using Posix;

void main (string[] argv) {

    string a = "hello";
    string b = a;
    Posix.stdout.printf("a = %p\n", &a);
    Posix.stdout.printf("b = %p\n", &b);
}
///

Which yields:

a = 0x7fff5fbff890
b = 0x7fff5fbff880

Obviously two different addresses (pointer values).

Also changing b does not change a.

This is very confusing, from a C (or C++) point of view !

The Vala references, look more like Python (implicit) references than
like C (explicit) references.

Obviously, they are not ordinary C pointers as in :

///
char * a = "Hello";
char * b = a;
///

Serge.




On Mon, Jun 20, 2011 at 11:11 PM, Daniel Alonso <[email protected]> wrote:
> Please read the Vala Tutorial, specially the section "Datatypes" where
> it explains which types in vala qualify as reference types and which
> ones qualify as value types.
>
> Reference types when an assignment without the "new" operator behave
> as pointers.
>
> El dilluns 20 de juny de 2011, Daniel Alonso <[email protected]> ha 
> escrit:
>> Hi, you have to use the "new" operator in order to create a new
>> instance of a class. Any assignment of a variable to an existing
>> instance is just a reference to the same instance.
>>
>> Best regards.
>>
>> El dilluns 20 de juny de 2011, Serge Hulne <[email protected]> ha escrit:
>>> How can it be checked ?
>>>
>>> Serge.
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: tecywiz121 <[email protected]>
>>> Date: Mon, Jun 20, 2011 at 9:55 PM
>>> Subject: Re: [Vala] What is the right syntax for defining pointers or
>>> references or "aliases" in Vala ?
>>> To: Serge Hulne <[email protected]>
>>> Cc: vala-list <[email protected]>
>>>
>>>
>>>
>>>
>>> I'm not an expert, but I'm pretty sure that with classes, assignment
>>> means setting the variable to point to the object, and increasing the
>>> object's reference count.
>>>
>>
>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to