Re: [Vala] Genie and extra '\n' in some strings



Since Genie imitates Python perhaps it does it because Python does it in
most cases. See this page:
http://docs.python.org/reference/simple_stmts.html#print

Steven N. Oliver


On Fri, Jan 6, 2012 at 8:30 AM, Piotr Borkowski <rezyder gmail com> wrote:

Thank you for your reply, Abderrahim.

As you can see, in both cases the newline is added to a print'ed string,
so I guess it is intentional.

I think this is intentional, but I do not understand why it has been
applied. This seems unnecessary.

After compiling the functional equivalent of that program in Vala,
such additions do not occur.

Programs in C are the same except those strange extras in Genie version.


// hello.vala
public static void main (string[] args)
{
      var caption = "Hello World!\n";
      var hello = new HelloWorld ();
      var message = hello.say (caption);
      print ("Message: %s\n", message);
}

class HelloWorld : Object
{
      public string say (string greeting)
      {
              print (greeting);
              return "OK";
      }
}


// hello.c - vala version

...

void _vala_main (gchar** args, int args_length1) {
      gchar* _tmp0_;
      gchar* caption;
      HelloWorld* _tmp1_;
      HelloWorld* hello;
      gchar* _tmp2_ = NULL;
      gchar* message;
      _tmp0_ = g_strdup ("Hello World!\n");
      caption = _tmp0_;
      _tmp1_ = hello_world_new ();
      hello = _tmp1_;
      _tmp2_ = hello_world_say (hello, caption);
      message = _tmp2_;
       g_print ("Message: %s\n", message);
       _g_free0 (message);
      _g_object_unref0 (hello);
      _g_free0 (caption);
}

...

gchar* hello_world_say (HelloWorld* self, const gchar* greeting) {
      gchar* result = NULL;
      const gchar* _tmp0_;
      gchar* _tmp1_;
       g_return_val_if_fail (self != NULL, NULL);
      g_return_val_if_fail (greeting != NULL, NULL);
      _tmp0_ = greeting;
       g_print ("%s", _tmp0_);
      _tmp1_ = g_strdup ("OK");
      result = _tmp1_;
      return result;
}

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



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