Re: [Vala] Question regarding passing a strings as arguments to a method
- From: Serge Hulne <serge hulne gmail com>
- To: Phil Housley <undeconstructed gmail com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Question regarding passing a strings as arguments to a method
- Date: Mon, 11 Jul 2011 18:15:42 +0200
All right,
But it is a rather odd class indeed then, because:
1) I dont't think it has the value "null" when unassigned.
2) It derogates to the rule according to which the default behaviour in an
assignment between class types is by reference (when a string is assigned to
another, the default is to copy the data, unless it is explicitly declared
"unowned")
3) When a string is created, it does not require the use of the keyword
"new"
( it is: string s = "hello"; not: string s = new string("hello"); )
4) Yet, it is passed by reference in a function call.
Since the string class, seems to behave unlike any other class, perhaps its
singular behaviour ought to be emphasized in the documentation.
Serge.
On Mon, Jul 11, 2011 at 5:45 PM, Phil Housley <undeconstructed gmail com>wrote:
On 11 July 2011 13:03, Serge Hulne <serge hulne gmail com> wrote:
A string in Vala is a *reference* type [1] and therefore passed by
Not according to the documentation:
Cf Vala tutorial:
"Reference Types
The reference types are all types declared as a class, regardless of
whether they are descended from GLib's Object or not. Vala will ensure
that when you pass an object by reference the system will keep track
of the number of references currently alive in order to manage the
memory for you. The value of a reference that does not point anywhere
is null. More on classes and their features in the section about
object oriented programming."
Actually, string is a classed type, see
http://git.gnome.org/browse/vala/tree/vapi/glib-2.0.vapi#n1032
It isn't the most convenient class, since strings are used raw, with
no wrapping for extra features (like reference counting etc,) but in
general behaves like other classed types.
That is why I sought to clarify this point
Serge.
reference. The documentation is correct here, it may just need to
point out clearly that fact.
HTH,
Abderrahim
[1] it is a bit special because it is immutable, and thus copied
whenever there is a new strong reference to it
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
--
Phil Housley
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]