[Vala] Array concatenation (bug)



Hello folks,

I have a function, that gets an array (owned), needs to copy it n times, add
a different member to each copy and pass that on (recursively). I have two
issues:

 1) I've done it like this:

    function(owned Something[] array) {
        for(...) {
            var copy = array;
            copy += new_item;
            function((owned)copy);
        }
    }

    I would prefer if I could write that as an expression. Is there a way?

 2) From the logic that 'a += b' is supposed to be a shortcut (with
    optimization) for 'a = a + b', I tried:

    function(owned Something[] array) {
        for(...) {
            function(array + new_item);
        }
    }

    This:
        - Was silently passed by vala compiler.
        - Died a horrible death in the C compiler because the emited
          expression involved addition of 'Something *' to 'Something', which
          obviously wouldn't compile when Something is a struct.

    What is a '+' on arrays supposed to do in vala?

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



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