Aspect oriented programming: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
m (→{{header|J}}: make example slightly easier for a casual reader to follow) |
||
Line 204: | Line 204: | ||
For example, the phrase <code>([echo)</code> prints a value to the screen but is otherwise an identity function. (We could replace <code>echo</code> with an arbitrarily elaborate logging statement if we wished.) And, we can insert this statement into the middle of an expression to gain insight into its progress. |
For example, the phrase <code>([echo)</code> prints a value to the screen but is otherwise an identity function. (We could replace <code>echo</code> with an arbitrarily elaborate logging statement if we wished.) And, we can insert this statement into the middle of an expression to gain insight into its progress. |
||
Thus, <lang> -/p:i.5 NB. a mysterious expression |
Thus, <lang> <-/p:i.5 NB. a mysterious expression |
||
┌─┐ |
|||
⚫ | |||
│8│ |
|||
⚫ | |||
└─┘ |
|||
⚫ | |||
0 1 2 3 4 |
0 1 2 3 4 |
||
┌─┐ |
|||
8 |
|||
│8│ |
|||
⚫ | |||
└─┘ |
|||
⚫ | |||
2 3 5 7 11 |
2 3 5 7 11 |
||
┌─┐ |
|||
8 |
|||
│8│ |
|||
⚫ | |||
└─┘ |
|||
⚫ | |||
11 |
11 |
||
_4 |
_4 |
||
9 |
9 |
||
_6 |
_6 |
||
┌─┐ |
|||
8 |
|||
│8│ |
|||
⚫ | |||
└─┘ |
|||
⚫ | |||
7 |
7 |
||
5 |
5 |
||
3 |
3 |
||
2 |
2 |
||
┌─┐ |
|||
8 |
|||
│8│ |
|||
⚫ | |||
└─┘ |
|||
⚫ | |||
11 |
11 |
||
7 |
7 |
||
Line 233: | Line 243: | ||
_6 |
_6 |
||
2 |
2 |
||
┌─┐ |
|||
⚫ | |||
│8│ |
|||
└─┘ |
|||
<([echo)-/p:i.5 NB. show the right argument to < |
|||
⚫ | |||
┌─┐ |
|||
│8│ |
|||
⚫ | |||
Or, generally speaking, J provides us with the ability to wrap arbitrary statements with information gathering statements while allowing the original expression to proceed. (And, if we enable debugging, this information gathering can examine the surrounding context, gathering and reporting information on the calling environment, inspecting the local symbol table, the names of routines, the defining script(s), etc.) |
Or, generally speaking, J provides us with the ability to wrap arbitrary statements with information gathering statements while allowing the original expression to proceed. (And, if we enable debugging, this information gathering can examine the surrounding context, gathering and reporting information on the calling environment, inspecting the local symbol table, the names of routines, the defining script(s), etc.) |