Re: [Vala] Question regarding passing a strings as arguments to a method

It is correct in a sense, but again it is misleading.

- A C++ programmer might interpret it as: f(std::string s), which
implies a copy, as opposed to: f(std::string& s).
- A Visual Basic programmer might interpret it as : f(ByVal test As
String) which is obviously not what is intended.

I am not saying, the documentation in inaccurate, I a merely pointing
out the fact that uses an ellipsis, therefore it is concise, but
ambiguous and can be misleading.

"By reference" means the address of the variable, not of the object.

Ok, but then it worth saying so explicitly to lift the ambiguity.


On Mon, Jul 11, 2011 at 8:34 AM, Luca Bruno <lethalman88 gmail com> wrote:

On Mon, Jul 11, 2011 at 07:10:45AM +0200, Serge Hulne wrote:
If one has a look at the C code generated by Vala for the following
two examples, it appears that the "unowned" keyword has no influence
on the way
the string b (of type gchar*) is passed to f().

In both cases, it is passed as a pointer (without duplication).

Therefore it seems to me that the Vala tutorial is slightly misleading
and should read:

- "In Vala strings are always passed by address".

The documentation is correct, the "value" here is the reference itself.
"By reference" means the address of the variable, not of the object.

-- - The Universal Operating System

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