Constructor semantics

From: Date: Thu, 11 Nov 2004 05:34:45 +0000
Subject: Constructor semantics
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-771@lists.php.net to get a copy of this message
Hi gang, I am at point in working on generator where we need to figure out how constructors should function. I have 2 issues to discuss. Gtk2 allows for a property based constructor invocation, something like: GtkAlignment *align = (GtkAlignment *)g_object_newv(GTK_TYPE_ALIGNMENT, "xalign", 1.0, "yalign", 0.0, "xscale", 0.5, NULL); The old style was: GtkAlignment *align = gtk_alignment_new(1.0, 0.0, 0.0, 1.0); PyGtk has utilized this to make generation of constructors easier. The properties are defined in the .defs file, the generator parses them and generates property based constructor that can be invoked as: align = gtk.GtkAlign(xalign = 1.0, yalign = 0.0, xscale = 0.5) or something like that. The old style of constructors is not deprecated, so it's still possible to invoke it as: align = gtk.GtkAlign(1.0, 0.0, 0.5); So, in our case, should we just stick with how PHP-GTK1 constructors worked or should we try to allow pseudo-keyword invokation? $align = new GtkAlignment(array('xalign' => 1.0, 'yalign' => 0.0, 'xscale' => 0.5)); The second question is what should we do if constructor encounters an error. In PHP-GTK 1 we invalidated $this variable (setting it to NULL), but in PHP-GTK 2 I am tempted to raise an exception. -Andrei

« previous php.gtk.dev (#771) next »