Re: [Vala] ref // unref syntax.



On Mon, 2007-04-16 at 18:15 -0300, Alexandre Moreira wrote:
Hello, everyone.

I've been playing around with manual memory management these days...
and I must say, the syntax we have right now (@ref and unref methods)
is not really nice.

First of all: we have this assimetric behavior (one with the @ and the
other without it).

You can prefix any identifier you want with the @ sign, so use @ref and
@unref if you like that better.

Second: It turns the syntax highlight for the ref keyword, even though
it is a method name, in most editors I've tried (C# syntax).

Yes, that's a bit unfortunate. Editors which fully support the C# syntax
should recognize the @ sign and not highlight @ref as keyword but some
editors don't support that.

So, I was wondering, would it be possible to have ref//unref Object
operators ? something in the lines of:

MyClass obj;

ref obj;

unref obj;

I've been thinking about the subject and I think there could be some
ambiguity problems (I don't think there will, though, if we keep both
operators without a return value, and add it to the language as
another kind of statement...like

Statement => ReferenceOperator Identifier { ... }

But, if you think this will cause big problems, please, at least
change the default names for the ref//unref methods to something that
at least is simmetric (like REF / UNREF or _ref / _unref)... these
options are ugly, but at least it makes sense.

It would be possible without conflict, I guess. It's not that unusual to
use the fact that ref() returns the reference, though, so I'm not sure
whether I like the idea that much.

If you have other syntax ideas for memory management, please tell us.

BTW: Is there a specific reason why you can't use the assisted memory
management or is it just that you are used to manage references
yourself?

Jürg




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