Re: [Vala] GBinding support?

2010-06-21 Thread Fredderic Unpenstein
On 21 June 2010 01:57, Frederik scumm_fr...@gmx.net wrote:
 GLib/GObject 2.26 will add property binding [1]. The straightforward way to
 support this in Vala would be:
  Object.bind_property (foo, x, bar, y);
  Object.bind_property (foo, x, bar, y, BindingFlags.BIDIRECTIONAL);

Would foo.x.bind_property be a possibility?  And perhaps
bind_bidirectional or bind_with (do you bind anything else, other than
properties, on an object property?)...  Maybe then also bind_property
could become bind_to or something equaly less redundant?

Also, is there any way to get rid of the need for BindingFlags in
that?  If the argument IS a BindingFlags, Vala could include that
scope when looking up bare words...?


 However, this is not very type-safe. Would direct language support be
 reasonable? E.g. something like

  foo.x + bar.y;       // default
  foo.x + bar.y;      // bidirectional

 Or is it too cryptic?

There's also := type notation, which fels like more than assignment.
 Though since binding takes flags, I worry that it'll end up going the
same way as += for signal connection.

Personaly, I like the operators, but they're a little limited once you
add extra varients or options, as with the connect family.  Unless
some syntax is added for general operator functions...  eg:

   foo.x + [BIDIRECTIONAL] bar.y;

which could also make += signal connection useful again.  Perhaps
adding support for a bracketed comma-separated list with the extra
arguments, instead.


 And how to deal with 'g_object_bind_property_full'? It takes two 
 TransformFuncs
 but only one user_data/GDestroyNotify pair.
  (foo.x, celsius_to_fahrenheit) + (bar.y, fahrenheit_to_celsius);
  (foo.x, (b, s, t) = { }) + (bar.y, (b, s, t) = { });

That's sort of what I was saying with bracketing above, too.  A
general syntax pattern like that might help with other places where
syntactic support would be useful but presently shunned.


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


Re: [Vala] GBinding support?

2010-06-21 Thread Frederik
Am 21.06.2010 09:29, Fredderic Unpenstein wrote:
 On 21 June 2010 01:57, Frederik scumm_fr...@gmx.net wrote:
 GLib/GObject 2.26 will add property binding [1]. The straightforward way to
 support this in Vala would be:
  Object.bind_property (foo, x, bar, y);
  Object.bind_property (foo, x, bar, y, BindingFlags.BIDIRECTIONAL);
 
 Would foo.x.bind_property be a possibility?  And perhaps
 bind_bidirectional or bind_with (do you bind anything else, other than
 properties, on an object property?)...  Maybe then also bind_property
 could become bind_to or something equaly less redundant?

A problem is that 'foo.x' will evaluate to the value of the property,
not representing the property itself. So, if you write

  foo.x.bind_property (bar.y);

and if 'foo.x' is 4 and 'bar.y' is 5 it would essentially mean

  4.bind_property (5);

 Personaly, I like the operators, but they're a little limited once you
 add extra varients or options, as with the connect family.  Unless
 some syntax is added for general operator functions...  eg:
 
foo.x + [BIDIRECTIONAL] bar.y;
 
 which could also make += signal connection useful again.  Perhaps
 adding support for a bracketed comma-separated list with the extra
 arguments, instead.

Personally, I prefer descriptive names over symbolic operators. The question
is whether the property binding feature is essential enough to justify extra
syntax (keyword, operator) just to be type safe.

 And how to deal with 'g_object_bind_property_full'? It takes two 
 TransformFuncs
 but only one user_data/GDestroyNotify pair.
  (foo.x, celsius_to_fahrenheit) + (bar.y, fahrenheit_to_celsius);
  (foo.x, (b, s, t) = { }) + (bar.y, (b, s, t) = { });
 
 That's sort of what I was saying with bracketing above, too.  A
 general syntax pattern like that might help with other places where
 syntactic support would be useful but presently shunned.
 
 
 Fredderic
 

Best regards,

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


Re: [Vala] GBinding support?

2010-06-21 Thread Frederik
Am 21.06.2010 05:51, Matias De la Puente wrote:
 This stuff is great! very helpful for my project :)
 
 My suggestions:
 
 public class foo : Object
 {
   public int x { set; get; }
   public int y { set; get; }
 }
 
 public class bar : Object
 {
   private Foo foo = new Foo ();
   
   //One possibility
   public int x { set; get; } as foo.x;
   public int y { private set; get; } as foo.y;//one direction
   
   //Another possibility
   public int x { set; get; } bind foo.x;
   public int y { private set; get; } bind foo.y;  //one direction
 }
 
 Matias

And what if you want to bind to a property of an object not yet instantiated
at construction time?


Best regards,

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


Re: [Vala] GBinding support?

2010-06-21 Thread Jürg Billeter
Hi,

On Sun, 2010-06-20 at 17:57 +0200, Frederik wrote:
 GLib/GObject 2.26 will add property binding [1]. The straightforward way to
 support this in Vala would be:
 
   Object.bind_property (foo, x, bar, y);
   Object.bind_property (foo, x, bar, y, BindingFlags.BIDIRECTIONAL);
 
 However, this is not very type-safe. Would direct language support be
 reasonable? E.g. something like
 
   foo.x + bar.y; // default
   foo.x + bar.y;// bidirectional
 
 Or is it too cryptic?

We don't need special syntax for every available GObject method. Let's
first have a plain binding and see how it will be used. If we see a very
common pattern where syntactic sugar would help a lot, we can reconsider
adding syntactic sugar.

 And how to deal with 'g_object_bind_property_full'? It takes two 
 TransformFuncs
 but only one user_data/GDestroyNotify pair.

This will be fixed, I talked to ebassi on IRC.

Jürg

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


[Vala] GBinding support?

2010-06-20 Thread Frederik
Hi,

GLib/GObject 2.26 will add property binding [1]. The straightforward way to
support this in Vala would be:

  Object.bind_property (foo, x, bar, y);
  Object.bind_property (foo, x, bar, y, BindingFlags.BIDIRECTIONAL);

However, this is not very type-safe. Would direct language support be
reasonable? E.g. something like

  foo.x + bar.y;   // default
  foo.x + bar.y;  // bidirectional

Or is it too cryptic?

And how to deal with 'g_object_bind_property_full'? It takes two TransformFuncs
but only one user_data/GDestroyNotify pair.

And how could syntax support, if any, look like?

  (foo.x, celsius_to_fahrenheit) + (bar.y, fahrenheit_to_celsius);
  (foo.x, (b, s, t) = { }) + (bar.y, (b, s, t) = { });

?


Best regards,

Frederik


[1] http://library.gnome.org/devel/gobject/unstable/GBinding.html
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GBinding support?

2010-06-20 Thread Fabian Deutsch
Hello,

Am Sonntag, den 20.06.2010, 17:57 +0200 schrieb Frederik:
   foo.x + bar.y;   // default
   foo.x + bar.y;  // bidirectional 

I'd suggest ~ or -, because a change of a 'implies' a value change of
b:
  foo.x ~ bar.y;   // default
  foo.x ~ bar.y;  // bidirectional 

- fabian


smime.p7s
Description: S/MIME cryptographic signature
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GBinding support?

2010-06-20 Thread Matias De la Puente
This stuff is great! very helpful for my project :)

My suggestions:

public class foo : Object
{
public int x { set; get; }
public int y { set; get; }
}

public class bar : Object
{
private Foo foo = new Foo ();

//One possibility
public int x { set; get; } as foo.x;
public int y { private set; get; } as foo.y;//one direction

//Another possibility
public int x { set; get; } bind foo.x;
public int y { private set; get; } bind foo.y;  //one direction
}

Matias

El dom, 20-06-2010 a las 18:06 +0200, Fabian Deutsch escribió:
 Hello,
 
 Am Sonntag, den 20.06.2010, 17:57 +0200 schrieb Frederik:
foo.x + bar.y;   // default
foo.x + bar.y;  // bidirectional 
 
 I'd suggest ~ or -, because a change of a 'implies' a value change of
 b:
   foo.x ~ bar.y;   // default
   foo.x ~ bar.y;  // bidirectional 
 
 - fabian
 ___
 vala-list mailing list
 vala-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/vala-list


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