Gentoo Archives: gentoo-user

From: Alec Ten Harmsel <alec@××××××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Don't disable 'introspection'
Date: Thu, 16 Jul 2015 23:19:39
Message-Id: 55A83BF9.90007@alectenharmsel.com
In Reply to: Re: [gentoo-user] Don't disable 'introspection' by Alan McKinnon
1 On 07/16/2015 05:16 PM, Alan McKinnon wrote:
2 > On 16/07/2015 22:53, walt wrote:
3 >>
4 >> If anyone can splain what introspection does I'd be grateful.
5 > It's a tricky concept if you haven't worked with Object Oriented
6 > Programming, so lt's look at the USE description:
7 >
8 > introspection - Add support for GObject based introspection
9 >
10 > Doesn't say much, right?
11 >
12 > Object Oriented languages tend to compile to byte-code, just like Java
13 > does, and so does Python. It's so the run-time interpreter can look up
14 > at run-time which function exactly needs to be run (this can't be
15 > determined statically).
16
17 Yes, but introspection (as a part of the language specification) is not
18 limited to object oriented languages, nor compiled to byte code
19 languages. C++'s 'virtual' keyword can (sometimes) force the compiler to
20 generate introspection code if it absolutely cannot determine which
21 function to call at compile time. C++'s templates could (maybe?) be
22 considered static introspection.
23
24 > A really neat trick is to "look inside" objects
25 > not just to see what it has, but also how the innards work, what
26 > properties an object has, and other neat stuff. That's what introspect
27 > means - to "look inside". This magic is what makes dynamic IDEs
28 > possible, where they prompt you for all manner of stuff while typing
29 > code, and even generate boiler-plate code that it hasn't been hard-coded
30 > to deal with.
31 >
32 > All sounds very fancy and theoretical. I know what introspection does,
33 > but I can't know if I need this type of it or not. Apparently (because
34 > stuff breaks horribly when it's off), packages that use GObject seem to
35 > rely on this feature.
36
37 It is very nice and very fancy, but the implementation is not incredibly
38 complicated in most languages (just pointers to tables of functions if
39 memory serves). If anyone is interested in playing around with this
40 stuff, Ruby has a pretty advanced object model, and classes can have
41 different function implementations depending on what module you're in.
42
43 Alec