On Sat, 2008-02-16 at 11:43 -0800, Shawn Ferris wrote:
> Hey All -- I'm new to vala and while I've wanted to learn C, I just haven't 
> had a need for it. I'm an Oracle DBA and perl+dbi suites me very well. But, 
> alas, I want to take the plunge and would like to write some gnome 
> applications. I've come quite accustomed to writing OO-Perl and I had been 
> looking at C# because the syntax looked very logical to me. But then I ran 
> into vala and gotta say, this is the direction I see myself going for two 
> reasons.. Again, the syntax looks logical and in the end, it generates C so 
> I'll get more fimiliar with that as well. Best of both worlds. 8D
> 
> That being said.. I'm sure I will have a ton of obvious questions... such as, 
> string concatenation.. I'm trying this:
> 
> public class SMF : GLib.Object {
> 
>   private const string FOO  = "foo";
>   private const string BAR  = "bar";
>   private const string BAZ  = FOO + BAR;
> 
>   public static int main () {
>  
>     message(BAZ);
> 
>     return 0;
>   }
> }
> 
> And you'll probably guess that my error is:
> 
>   error: invalid operands to binary +
> 
> And if I try:
> 
>   private const string BAZ  = "%s %s".printf(FOO, BAR);
> 
> I get:
> 
>   error: initializer element is not constant
> 
> So.. would someone be so kind as to tell me how this is done? I would 
> appreciate it!
> 
> Thx
> SMF 8D
> 
> 
> 
> 
> 
> 
>       
> ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> _______________________________________________
> Vala-list mailing list
> Vala-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/vala-list

Hi Shawn,

vala compiler has a bug when you try to use string concatenation
operator in variable initializers (see
http://bugzilla.gnome.org/show_bug.cgi?id=516287)

As a temporary workaround you can write your example like this:

public class SMF : GLib.Object {

  private const string FOO  = "foo";
  private const string BAR  = "bar";
  private string BAZ;

  public static int main () {
 
    BAZ = FOO + BAR;
    message(BAZ);

    return 0;
  }
}

mind that you have lost the const modifier in BAZ ;)

Bye,
A.

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to