[Vala] Construction of generic instantiations
- From: Andy Lees <andrewl oz gmail com>
- To: Vala List <vala-list gnome org>
- Subject: [Vala] Construction of generic instantiations
- Date: Wed, 17 Feb 2016 09:51:04 +1100
Hi,
I seems that the setting of the hidden type variable in generic
instantiations occurs in the new operation, rather than in the constructor,
so if I have a class:
public class Makeable<T> : GLib.Object {
construct {
x = (int)typeof (T);
message ("Makeable in Construction, T = %ld", (long)typeof (T));
}
public int x;
public Makeable() {
message ("In new x = %d T = %ld", x, (long)typeof (T));
}
public Type typ() {
return typeof (T);
}
}
then I get:
** Message: test5.vala:18: Makeable in Construction, T = 4
** Message: test5.vala:22: In new x = 4 T = 24
when I construct via new ...
and only:
** Message: test5.vala:18: Makeable in Construction, T = 4
when I construct with Object.new.
This means that generic instances cannot be properly constructed via
Object.new, which appears to be a significant issue.
Is there any reason why the setting of the hidden type variable ( and any
other generic instance initialisations) cannot be done in the construct
function prior to user code? Then generic instances could be made via
Object.new like other objects.
Regards,
Andrew Lees
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]