GNOME Bugzilla – Bug 573075
typeof should also accept instances.
Last modified: 2010-05-27 21:16:28 UTC
Please describe the problem: typeof operator should also accept instances. just like how sizeof operator behaves in C. this is feasible for GObject objects and GTypeInstance objects, since G_TYPE_FROM_INSTANCE is always available to obtain the type from the instance at run time. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
try using: GLib.Type.from_instance (my_instance); //returns a GLib.Type or stdout.printf ("%s\n", GLib.Type.from_instance (my_instance).name ()); //prints the type's string representation.
Flagging as enhancement. Jürg needs to decide here. I would welcome the proposed addition as a convenient shortcut.
(In reply to comment #2) > Flagging as enhancement. Jürg needs to decide here. I would welcome the > proposed addition as a convenient shortcut. There's also obj.get_type() which is as short as typeof().
typeof can only be used for static typing. This is intentional. obj.get_type () is the proper way to get the runtime type. *** This bug has been marked as a duplicate of bug 562063 ***