CSC/ECE 517 Fall 2010/ch1 1c NR: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 5: Line 5:
*Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning.
*Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning.
What is crucial here is that a given program can behave not only as a function, but also as a data structure that can be examined and manipulated to change its behavior. These properties lead to an easily extensible language since the structures used by the language implementation are accessible to the programmer. The programmer can now define programming constructs that would otherwise have been either impossible or extremely difficult to define. These properties have led to the adoption of reflection as a primary means for language extensibility.
What is crucial here is that a given program can behave not only as a function, but also as a data structure that can be examined and manipulated to change its behavior. These properties lead to an easily extensible language since the structures used by the language implementation are accessible to the programmer. The programmer can now define programming constructs that would otherwise have been either impossible or extremely difficult to define. These properties have led to the adoption of reflection as a primary means for language extensibility.
Reflection is most commonly used in many dynamically typed languages such as '''[http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby]''''''[http://en.wikipedia.org/wiki/Smalltalk Smalltalk]''', '''[http://en.wikipedia.org/wiki/Objective-C Objective-c]''' and scripting languages like '''[http://en.wikipedia.org/wiki/Perl Perl]''','''[http://en.wikipedia.org/wiki/PHP PHP]'''. Statically typed languages such as Java, '''[http://en.wikipedia.org/wiki/ML_(programming_language) ML]''' or '''[http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell]''' also support reflection.
Reflection is most commonly used in many dynamically typed languages such as '''[http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby]''','''[http://en.wikipedia.org/wiki/Smalltalk Smalltalk]''', '''[http://en.wikipedia.org/wiki/Objective-C Objective-c]''' and scripting languages like '''[http://en.wikipedia.org/wiki/Perl Perl]''','''[http://en.wikipedia.org/wiki/PHP PHP]'''. Statically typed languages such as Java, '''[http://en.wikipedia.org/wiki/ML_(programming_language) ML]''' or '''[http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell]''' also support reflection.


=Reflection as a Language Feature=
=Reflection as a Language Feature=

Revision as of 21:11, 7 September 2010

Introduction to Reflection

Reflection was introduced by Brian Cantwell Smith as a framework for language extension. Reflection is the ability of a computer program to manipulate aspects of a program from within itself at runtime. There are two aspects of such manipulation: introspection and intercession.

  • Introspection - the ability for a program to observe and reason about its own state.
  • Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning.

What is crucial here is that a given program can behave not only as a function, but also as a data structure that can be examined and manipulated to change its behavior. These properties lead to an easily extensible language since the structures used by the language implementation are accessible to the programmer. The programmer can now define programming constructs that would otherwise have been either impossible or extremely difficult to define. These properties have led to the adoption of reflection as a primary means for language extensibility. Reflection is most commonly used in many dynamically typed languages such as Ruby,Smalltalk, Objective-c and scripting languages like Perl,PHP. Statically typed languages such as Java, ML or Haskell also support reflection.

Reflection as a Language Feature

Reflection as Package

Reflection as Language Feature vs Reflection as Package

Summary

References