Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-18 Thread Jürg Billeter
On Fri, 2009-09-18 at 10:11 +0200, Frederik wrote:
 Great release!

Thanks.

 One question about closures: is it intentional that captured variables
 change after the closure? For example:
 
 --
 delegate void Func ();
 
 void main () {
   int a = 42;
   Func f = () = stdout.printf (%d\n, a);
   a = 43;
   f ();
 }
 --
 Output: 43

This is correct, there is only one instance of the variable `a' and that
instance is captured by the closure. You can also change the value of
`a' inside the closure and this will affect the outer method as well as
there is only one instance of this variable.

 This seems to affect currying as well:
 
 --
 delegate int IntFuncInt (int i);
 
 IntFuncInt curried_add (int a) {
 return b = a + b;
 }
 
 void main () {
   int a = 3;
   int b = 4;
   stdout.printf (%d + %d = %d\n, a, b, curried_add (a)(b));
 }
 --
 Output: 3 + 4 = 4

This was a bug in how delegates were returned from methods. This is now
fixed in master.

Jürg

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


Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-18 Thread jp0409

Hi,

Thanks for the great release! Great progress!!

Then the bad news ;-) The output of this one is 0. Is this correct?

JP

---

delegate void Func ();

Func goo () {
int a = 42;
Func f = () = stdout.printf (%d\n, a);
a = 43;
return f;
}

void main () {
var f = goo ();
f ();
}

---


On Fri, 2009-09-18 at 10:11 +0200, Frederik wrote:
 Great release!

Thanks.

 One question about closures: is it intentional that captured variables
 change after the closure? For example:
 
 --

 delegate void Func ();
 
 void main () {

int a = 42;
Func f = () = stdout.printf (%d\n, a);
a = 43;
f ();
 }
 --
 Output: 43

This is correct, there is only one instance of the variable `a' and that
instance is captured by the closure. You can also change the value of
`a' inside the closure and this will affect the outer method as well as
there is only one instance of this variable.

 This seems to affect currying as well:
 
 --

 delegate int IntFuncInt (int i);
 
 IntFuncInt curried_add (int a) {

 return b = a + b;
 }
 
 void main () {

int a = 3;
int b = 4;
stdout.printf (%d + %d = %d\n, a, b, curried_add (a)(b));
 }
 --
 Output: 3 + 4 = 4

This was a bug in how delegates were returned from methods. This is now
fixed in master.

Jürg

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



--


__
Saunalahdelta mullistava uutuus Nokia N97 ja kaiken kattava TotaaliMAX nyt 
ennakkomyynnissä uskomattoman edullisesti! Paketissa puhelut ja viestit (3000 
min/kpl/kk), huippunopea mobiililaajakaista sekä Nokia N97 yhdellä kk-maksulla 
vain 59,95 e/kk (24 kk sopimus).
Katso http://saunalahti.fi/totaalimax

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


Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-18 Thread Frederik
Jürg Billeter wrote:
 This is correct, there is only one instance of the variable `a' and that
 instance is captured by the closure. You can also change the value of
 `a' inside the closure and this will affect the outer method as well as
 there is only one instance of this variable.

You're right, I have tried it now with C# and it's the same behaviour.

 This was a bug in how delegates were returned from methods. This is now
 fixed in master.

Thanks!


Best regards,

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


Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-18 Thread Frederik
jp0...@jippii.fi wrote:
 Hi,
 
 Thanks for the great release! Great progress!!
 
 Then the bad news ;-) The output of this one is 0. Is this correct?

Seems to work now with Vala/master. Maybe it was the same bug as with my
second example.


Best regards,

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


Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-18 Thread jp0409

Already fixed? Great! Thanks!

JP


jp0...@jippii.fi wrote:
 Hi,
 
 Thanks for the great release! Great progress!!
 
 Then the bad news ;-) The output of this one is 0. Is this correct?


Seems to work now with Vala/master. Maybe it was the same bug as with my
second example.


Best regards,

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



--


__
Saunalahdelta mullistava uutuus Nokia N97 ja kaiken kattava TotaaliMAX nyt 
ennakkomyynnissä uskomattoman edullisesti! Paketissa puhelut ja viestit (3000 
min/kpl/kk), huippunopea mobiililaajakaista sekä Nokia N97 yhdellä kk-maksulla 
vain 59,95 e/kk (24 kk sopimus).
Katso http://saunalahti.fi/totaalimax

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


[Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system

2009-09-17 Thread Jürg Billeter
We are pleased to announce version 0.7.6 of Vala, a compiler for the
GObject type system.

Vala 0.7.6 is now available for download at:
   http://download.gnome.org/sources/vala/0.7/

Changes since 0.7.5
 * Add support for closures.
 * Improve support for asynchronous methods.
 * Support async methods in D-Bus servers.
 * Add clutter-1.0 bindings (Rob Taylor).
 * Add GVariant, GSettings, and dconf bindings (Ryan Lortie).
 * Add linux, libnl-1, and libasound bindings (Michael 'Mickey' Lauer).
 * Add gnutls bindings (Jiří Zárevúcky).
 * Add librest bindings (Adrien Bustany).
 * Many bug fixes and binding updates.

Vala is a new programming language that aims to bring modern programming
language features to GNOME developers without imposing any additional
runtime requirements and without using a different ABI compared to
applications and libraries written in C.

valac, the Vala compiler, is a self-hosting compiler that translates
Vala source code into C source and header files. It uses the GObject
type system to create classes and interfaces declared in the Vala source
code.

The syntax of Vala is similar to C#, modified to better fit the GObject
type system. Vala supports modern language features as the following:

* Interfaces
* Properties
* Signals
* Foreach
* Lambda expressions
* Type inference for local variables
* Generics
* Non-null types
* Assisted memory management
* Exception handling

Vala is designed to allow access to existing C libraries, especially
GObject-based libraries, without the need for runtime bindings. All that
is needed to use a library with Vala is an API file, containing the class
and method declarations in Vala syntax. Vala currently comes with
bindings for GLib and GTK+. It's planned to provide generated bindings for
the full GNOME Platform at a later stage.

Using classes and methods written in Vala from an application written in
C is not difficult. The Vala library only has to install the generated
header files and C applications may then access the GObject-based API of
the Vala library as usual. It should also be easily possible to write a
bindings generator for access to Vala libraries from applications
written in e.g. C# as the Vala parser is written as a library, so that
all compile-time information is available when generating a binding.

More information about Vala is available at

http://live.gnome.org/Vala


Jürg Billeter

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