On 07/16/2015 05:16 PM, Alan McKinnon wrote:
On 16/07/2015 22:53, walt wrote:
If anyone can splain what introspection does I'd be grateful.
It's a tricky concept if you haven't worked with Object Oriented
Programming, so lt's look at the USE description:
introspection - Add support for GObject based introspection
Doesn't say much, right?
Object Oriented languages tend to compile to byte-code, just like Java
does, and so does Python. It's so the run-time interpreter can look up
at run-time which function exactly needs to be run (this can't be
determined statically).
Yes, but introspection (as a part of the language specification) is not
limited to object oriented languages, nor compiled to byte code
languages. C++'s 'virtual' keyword can (sometimes) force the compiler to
generate introspection code if it absolutely cannot determine which
function to call at compile time. C++'s templates could (maybe?) be
considered static introspection.
A really neat trick is to "look inside" objects
not just to see what it has, but also how the innards work, what
properties an object has, and other neat stuff. That's what introspect
means - to "look inside". This magic is what makes dynamic IDEs
possible, where they prompt you for all manner of stuff while typing
code, and even generate boiler-plate code that it hasn't been hard-coded
to deal with.
All sounds very fancy and theoretical. I know what introspection does,
but I can't know if I need this type of it or not. Apparently (because
stuff breaks horribly when it's off), packages that use GObject seem to
rely on this feature.
It is very nice and very fancy, but the implementation is not incredibly
complicated in most languages (just pointers to tables of functions if
memory serves). If anyone is interested in playing around with this
stuff, Ruby has a pretty advanced object model, and classes can have
different function implementations depending on what module you're in.
Alec