Re: [Vala] Proper Syntax for Array of Nullable Strings



On Thu, Jan 21, 2010 at 01:04:47 +0100, "Andrés G. Aragoneses" wrote:
El 20/01/10 23:42, Sam Wilson escribió:
 Is it possible to define a nullable array of nullable strings? How?

However, I don't agree with Frederik here, because I think you cannot
and vala shouldn't let you in the future (in case someone thinks it's a
limitation) because, as far as I know, in C# for example an array can
already be null, so making it nullable is non-sense.

String is exactly as nullable in C# as an array. In vala the case is
different though, because:

 - Array is not really nullable, since null is simply a representation of an
   empty array and IIRC boxing of arrays is not supported (yet)(1), and
 - with --enable-experimental-non-null (as was the question in this thread),
   no variables are nullable unless declared as such (with ?)(2).

(1) Vala represents arrays using pair of variables, the pointer and the
    length. The pointer is NULL if length is 0. They are not
    reference-counted, limiting the ways they can be used. Boxing the two
    variables to an object would be possible, but IIRC vala can't currently
    do it.
(2) With --enable-experimental-non-null, vala uses static analysis to make
    sure all reference (object) variables get initialized with non-null
    values unless they are declared nullable.

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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