2
$\begingroup$

I imagine that this question has been asked before, yet I'm not able to find an answer using the form of the question I believe might be asked.

Is there a mechanism for duplicating the functionality of Aspect Oriented Programming (AOP).

For example, if one has an existing application that accesses a particular set of sensitive files, my desire would be to Log/Monitor/Intercept/Visualize access to and operations upon those files and their data.

Given my shallow faculty with Mathematica I envision that such might take the form:

Intercept[FileSystemScan, FunctionThatDecidesWhenBeforeAfterDuring, FunctionThatDecidesWhatToDo, FunctionThatHandlesErrors] 

Intercept[AllFunctionsWithSignatureFooOptionallyIncludingContext,FunctionthatDecidesWhen,FunctionThatDecidesWhat,FunctionThatHandlesErrors]

Or something to that effect.

I looked at Trace, yet that doesn't seem to be exactly that for which I am looking. Yet, perhaps I just do not fully understand it.

$\endgroup$
  • $\begingroup$ Have a look at UpValues $\endgroup$ – Sascha Sep 6 '16 at 18:07
  • $\begingroup$ @Sascha Thanks much. I confess I am having some conceptual difficulty with Up and Down Values. $\endgroup$ – LibertyTrooper Sep 7 '16 at 17:37
  • 1
    $\begingroup$ See (96) for discussion of up- and down-values. Up-values are a useful tool to crosscut advice into "call" join points where at least one of the join point arguments has a distinctive head. There is a widely used idiom known as the Villegas-Gayley trick that can wrap advice around a single function (i.e. with little or no crosscutting). $\endgroup$ – WReach Sep 9 '16 at 18:06
  • $\begingroup$ Also look at Leonid's withUserDefs function. $\endgroup$ – jkuczm Sep 19 '16 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.