Re: [Vala] Variable declaration.



On 3/11/07, Jürg Billeter <j bitron ch> wrote:
Hi Alexandre,

On Son, 2007-03-11 at 12:43 -0300, Alexandre Moreira wrote:
> Hey there, everyone.
>
> Can I use type names (class names, actually) while declaring variables
> or only the "var" keyword ?

Yes, you can use type names.

Oh, Great!


> If I can use the type names, what is the value of having the var
> keyword ? Anything specific needs it ? Just asking because I think it
> would be a pain in the neck to write some sort of code completion with
> variables defined with "var" lots of checking to do to find out its
> type.

There is no specific need currently, it just eases writing code
sometimes quite a bit. I wouldn't recommend to always use var as the
readability might suffer but statements like this
        HashMap<string,string> map = new HashMap<string,string> ();
are just nicer to write like that
        var map = new HashMap<string,string> ();

It doesn't make sense, in my opinion, to use it for basic types like
        var b = false;

It's planned to provide API in libvala that will make it easy to write
code completion support.

Well, thats great. I still think it would be wiser to drop var and
stick with the type names so stuff like ctags (used by a great deal of
Gvim/Emacs programmers out there) would work seamlessly with Vala, but
it is your call :)

Regards,
Alexandre Moreira.


Jürg





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