my $method = "hello"; my $f = $class->$constructor; $f->$method; # or $class->$constructor->$method; # with eval eval "new Foo->hello;"; PHP The following is an example in PHP: // Without reflection $foo = new Foo(); $foo->hello(); // With reflection, using Reflections API $reflector = new ReflectionClass("Foo"); $foo = $reflector->newInstance(); $hello = $reflector->getMethod("hello"); $hello->invoke($foo); Python The following is an example in Python: # Without reflection obj = Foo() obj.hello() # With reflection obj = globals()["Foo"]() getattr(obj, "hello")() # With eval eval("Foo().hello()") R The following is an example in R: # Without reflection, assuming foo() returns an S3-type object that has method "hello" obj <- foo() hello(obj) # With reflection class_name <- "foo" generic_having_foo_method <- "hello" obj <- do.call(class_name, list()) do.call(generic_having_foo_method, alist(obj)) Ruby The following is an example in Ruby: # Without reflection obj = Foo.new obj.hello # With reflection class_name = "Foo" method_name = :hello obj = Object.const_get(class_name).new obj.send method_name # With eval eval "Foo.new.hello" Xojo The following is an example using Xojo: ' Without reflection Dim fooInstance As New Foo fooInstance.PrintHello ' With reflection Dim classInfo As Introspection.Typeinfo = GetTypeInfo(Foo) Dim constructors() As Introspection.ConstructorInfo = classInfo.GetConstructors Dim fooInstance As Foo = constructors(0).Invoke Dim methods() As Introspection.MethodInfo = classInfo.GetMethods For Each m As Introspection.MethodInfo In methods If m.Name = "PrintHello" Then m.Invoke(fooInstance) End If Next See also List of reflective programming languages and platforms Mirror (programming) Programming paradigms Self-hosting (compilers) Self-modifying code Type introspection typeof References Citations Sources Jonathan M. Sobel and Daniel P. Friedman. An Introduction to Reflection-Oriented Programming (1996), Indiana University. Anti-Reflection technique using C# and C++/CLI wrapper to prevent code thief Further reading Ira R. Forman and Nate Forman, Java Reflection in Action (2005), Ira R. Forman and Scott Danforth, Putting Metaclasses to Work (1999), External links Reflection in logic, functional and object-oriented programming: a short comparative study An Introduction to Reflection-Oriented Programming Brian Foote's pages on Reflection in Smalltalk Java Reflection API Tutorial from Oracle Programming constructs Articles with example Python (programming language) code