Dynamic programming language: Difference between revisions

Content deleted Content added
Undid revision 824270362 by Aofzaz Sex (talk)
Functional programming is entirely orthogonal to dynamic programming languages. This section is off-topic and misleading.
Tag: section blanking
Line 18:
===Object runtime alteration===
A type or object system can typically be modified during runtime in a dynamic language. This can mean generating new objects from a runtime definition or based on [[mixin]]s of existing types or objects. This can also refer to changing the [[Inheritance (computer science)|inheritance]] or type tree, and thus altering the way that existing types behave (especially with respect to the invocation of [[Method (computer science)|methods]]).
 
===Functional programming===
[[Functional programming]] concepts are a feature of many dynamic languages, and also derive from Lisp.
 
====Closures====
One of the most widely used aspects of functional programming in dynamic languages is the [[Closure (computer science)|closure]], which allows creating a new instance of a function which retains access to the context in which it was created. A simple example of this is generating a function for scanning text for a word:
 
'''function''' new_scanner (word)
temp_function = '''function''' (input)
scan_for_text (input, word)
'''end function'''
'''return''' temp_function
'''end function'''
 
Note that the inner function has no name, and is instead ''stored'' in the variable <code>temp_function</code>. Each time <code>new_scanner</code> is executed, it will return a new function which remembers the value of the <code>word</code> parameter that was passed in when it was defined.
 
Closures<ref>
See example of use on p.330 of [[Larry Wall]]'s ''[[Programming Perl]]'' {{ISBN|0-596-00027-8}}
</ref> are one of the core tools of functional programming, and many languages support at least this degree of functional programming.
 
====Continuations====
Another feature of some dynamic languages is the [[continuation]]. Continuations represent execution states that can be re-invoked. For example, a parser might return an intermediate result and a continuation that, when invoked, will continue to parse the input. Continuations interact in very complex ways with scoping, especially with respect to closures. For this reason, many dynamic languages do not provide continuations.
 
===Reflection===