`new MyClass { prop1 = value1, ...}` shorthand for `(MyClass) Object.@new (typeof (MyClass), prop1, value1, ...)`
Description
I would like for Vala to support new ClassName { prop1 = value1, ...}
syntax (without parentheses after ClassName) for GObjects as a shorthand for (ClassName) Object.@new (typeof (ClassName), prop1, value1, ...)
.
Reasoning
-
This will make setting construct-only properties much easier since
Object.@new()
seems to be the only way to set them when instantiating. -
Right now if I want to instantiate
Gtk.Adjustment
, I can write eithervar adj = new Gtk.Adjustment (0, 0, 1, 0.05, 0.1, 0);
or
var adj = (Gtk.Adjustment) Object.@new (typeof (Gtk.Adjustment), "value", 0, "lower", 0, "upper", 1, "step-increment", 0.05, "page-increment", 0.1);
Both of which do not look readable, at least when compared to
var adj = new Gtk.Adjustment { value = 0, lower = 0, upper = 1, step_increment = 0.05, page_increment = 0.1 }; // Note that there are no parentheses after class name
Edited by Mazhar Hussain