Aspect oriented programming: Difference between revisions
Content added Content deleted
(F#) |
(Scala contribution added.) |
||
Line 131: | Line 131: | ||
Python has special syntax for [http://legacy.python.org/dev/peps/pep-0318/ decorators] acting on functions and methods, as well as [http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python metaclasses]. |
Python has special syntax for [http://legacy.python.org/dev/peps/pep-0318/ decorators] acting on functions and methods, as well as [http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python metaclasses]. |
||
=={{header|Scala}}== |
|||
Jones Bonér introduces AOP for Scala in [http://jonasboner.com/aop-style-mixin-composition-stacks-in-scala/ this blog]. |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
Tcl's <code>trace</code> command enables much AOP-like functionality, with variable traces allowing interception of accesses to variables, and command traces allowing interception of executions of procedures, etc. In addition, TclOO (Tcl's <!--main--> object system) also supports filter methods, which wrap around invocations of methods of an object (or all methods of a class) as a generalisation of before, after and around advice. This works well when combined with a mixin, allowing interception to be applied on a per-instance basis if desired. |
Tcl's <code>trace</code> command enables much AOP-like functionality, with variable traces allowing interception of accesses to variables, and command traces allowing interception of executions of procedures, etc. In addition, TclOO (Tcl's <!--main--> object system) also supports filter methods, which wrap around invocations of methods of an object (or all methods of a class) as a generalisation of before, after and around advice. This works well when combined with a mixin, allowing interception to be applied on a per-instance basis if desired. |
||
Line 156: | Line 158: | ||
puts ">>[xmpl calculate 2 3 5]<<"</lang> |
puts ">>[xmpl calculate 2 3 5]<<"</lang> |
||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
|||
::xmpl - called '::Example calculate' with '2 3 5' |
|||
⚫ | |||
::xmpl - |
::xmpl - result was '22' |
||
⚫ | |||
::xmpl - result was '22' |
|||
⚫ | |||
</pre> |