Questions tagged [introspection]

A capability of some object-oriented programming languages to determine the type of an object at runtime.

Some OOP languages providing Type Introspection ability : Ruby, Objective-C, C++, Java, PHP, Perl, Python, Object Pascal, Actionscript (as3)

The introspection is done differently, depending on the form of program, it is performed upon: inspecting a source code or compiled byte-code is called compile-time introspection, while inspecting properties of running code is a run-time introspection.

For example, Java supports both types of introspection: users of run-time introspection typically perform it via , while compile-time introspection can be implemented with tools or .

http://en.wikipedia.org/wiki/Type_introspection

1021 questions
-1
votes
1 answer

How can I get the frame data for a call to list.sort()?

I'm trying to access the frame information for a particular call to the list.sort method, but i am having trouble. import inspect def calm_pear(x): # compare cur_frame = inspect.currentframe() out_frames =…
Toothpick Anemone
  • 4,290
  • 2
  • 20
  • 42
-1
votes
1 answer

Can we get the object name using “this” pointer

I want to programmatically retrieve the identifier of a C++ class instance at runtime. I'm aware that C++ doesn't support reflection yet, but is there any alternative solution out there? For instance, given the following example: class Foo { …
Blaise Tine
  • 61
  • 1
  • 5
-1
votes
2 answers

Python: Modify variable bindings in calling scope

Is it possible to replace the function foo below with real code such that def foo(): #calling_scope()['a']=2 def bar(a): print(a) foo() print(a) bar(1) prints 1 2 ? To avoid an XY problem, what I really want is to have foo be…
Bananach
  • 2,016
  • 26
  • 51
-1
votes
2 answers

How to assert an `if` condition as truthy when an array is composed of undefined objects in Angular js

I have an array named as joinedArray. In one case, it has the value [undefined, undefined]. I have written one if condition like: if(joinArray === undefined){ vm.selectedFriends = []; angular.forEach($scope.contacts, function(contact){ …
Kevin
  • 653
  • 2
  • 13
  • 34
-1
votes
3 answers

Is it possible to differentiate between a non-capturing function and a closure in Javascript?

The two function objects: // toplevel var f1 = function(){return k;}; var f2 = (function(k){return function(){return k;}})(42); have the same source code "function(){return k;}" but f1 is a function where k is looked up in the global environment,…
6502
  • 112,025
  • 15
  • 165
  • 265
-1
votes
2 answers

Creating objects from strings

So I've read in some data from an XML: String arg1Value; String arg2Value; String arg2TypeAsString; String arg1TypeAsString; and I want to create an object: ObjectType(arg1Type, arg2Type); I'm trying this: (ObjectType)…
Aequitas
  • 2,205
  • 1
  • 25
  • 51
-1
votes
2 answers

Do Google Apps scripts permit any sort of introspection?

Can a Google Apps script learn its own name? or its id? Can it get the id of its containing folder? Can it learn where it resides in the folder hierarchy? Can script "A" get/set the properties of script "B"? Can script "A" edit any aspects of the…
Martin Bramwell
  • 2,003
  • 2
  • 19
  • 35
-1
votes
2 answers

How to check whether a Groovy class overrides a parent's method

I have two Groovy classes, Child1 and Child2, which derive from an abstract parent class Parent. The parent class implements three methods, only different in their parameters (i.e. their method names are the same). Now I have an instance of the…
Matthias
  • 9,817
  • 14
  • 66
  • 125
-1
votes
2 answers

Seeking a different way in using Reflection or Introspection in Python

I'm refactoring some code, and I thought I could use a bit of Reflection! So, I have this for now: def f(self, clazz): [...] boolean = False if hasattr(clazz_instace, 'some_attribute'): setattr(clazz_instace, 'some_attribute',…
R.R.C.
  • 5,439
  • 3
  • 14
  • 19
-1
votes
1 answer

Can't run Spring 3 based web application on WebSphere?

I have a web application which is based on Spring 3.1.1. It runs perfectly fine on Apache Tomcat 7.0. However, when I run it on, IBM WebSphere Application Server V7.0, I am receiving an error: 00000020 HiddenInputTa E…
Arci
  • 6,647
  • 20
  • 70
  • 98
-2
votes
4 answers

Pass a string containing a function name and its arguments to another function.

I would like to pass a string to a function in C in which the function will parse out a function name, the arguments for the function, and its datatypes, and then call the function for me. What is the best approach?
johnkrishna
  • 160
  • 2
  • 11
-2
votes
1 answer

Print any object as a literal expression in python

I want to print objects, so that the result is a valid python expression and can be used to reconstruct equivalent value. Let's call this function printexp For example, printexp(['a', 1+2, (True, {'f': [0]}, 1/2)]) would return "['a', 3, (True,…
Monday Fatigue
  • 223
  • 1
  • 3
  • 19
-2
votes
1 answer

Is it possible in C++ to access a variable based on its name (introspection)

I was wondering if this is possible to do in C++. I have a function that takes user input for x and y bounds and I need to verify it, and it would be easier to do with one function. Is this possible in C++? Here's some pseudocode. void bounds(char…
Ryan Knutson
  • 108
  • 2
  • 14
-3
votes
2 answers

Python introspection: return function argument as a string?

Here is what I'd like to be able to do x = 1 f(x+3) # returns 'x+3' (a string) Is this possible? (Lisp and C can do this, but f would have to be a macro)
MWB
  • 11,740
  • 6
  • 46
  • 91
-3
votes
1 answer

Can anyone recommend a way to write a function that counts the number of fields in a struct? i.e. - pseudocode- 'for field in struct'

I want a C function that I can pass a structure to and it will return the number of fields/members within the structure. At the moment I've found the easiest way is to just make a table and add to the table anytime I add a struct to any of the…
PLuv
  • 9
  • 2
1 2 3
68
69