After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 573075 - typeof should also accept instances.
typeof should also accept instances.
Status: RESOLVED DUPLICATE of bug 562063
Product: vala
Classification: Core
Component: Objects
0.7.x
Other All
: Low enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-02-25 06:06 UTC by rainwoodman
Modified: 2010-05-27 21:16 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description rainwoodman 2009-02-25 06:06:38 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:
Comment 1 Andreas Brauchli 2009-02-26 23:57:36 UTC
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.
Comment 2 Michael 'Mickey' Lauer 2009-10-08 13:18:11 UTC
Flagging as enhancement. Jürg needs to decide here. I would welcome the proposed addition as a convenient shortcut.
Comment 3 Luca Bruno 2010-05-27 19:58:04 UTC
(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().
Comment 4 Jürg Billeter 2010-05-27 21:16:28 UTC
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 ***