Re: [Vala] Ownership syntax changes



On Fri, 2008-12-19 at 20:49 -0500, Jamie McCracken wrote:
On Sat, 2008-12-20 at 02:19 +0100, Hans Vercammen wrote:
On Fri, 2008-12-19 at 12:10 +0100, Jürg Billeter wrote:

      * `(owned)' cast replaces `#' reference transfer expression

Even less used, equally unintuitive. Example of new syntax:

string foo = (owned) bar;

I don't have a strong opinion on this since I don't really need it, but
using a cast expression feels a bit wrong. Not sure if we want to keep
the option open of having operator overloading, but what about something
like:

string foo <= bar;
or
string foo << bar;

 <= and << are already operators in use and would be confusing but i do
agree the use of cast syntax here is odd

I would suggest something thats not a cast but still clear:

string foo owns bar;

It needs to be an expression, as it can also be used as a method
argument, not just in assignments.

or

string foo = owned bar;

We could of course remove the parentheses, however, I don't really see
how this should be more intuitive than my proposal. (owned) probably
stands out a bit more in the code, which is a good thing for rarely used
syntax.

I proposed a cast syntax as a short for a full cast including the type
and modifier:

    string foo = (owned string) bar;

Just like with a cast, we still refer to the same object, we just also
modify ownership behavior.

Jürg




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