Aspect oriented programming: Difference between revisions

(Added Perl verbiage)
Line 182:
 
Of course, you can also simply redefine Perl 6 on the fly to be any language you want in the current lexical scope, so you are really only limited by your imagination in how you wish to express these "aspects", whatever you might mean by that term…
 
=={{header|Phix}}==
{{trans|Go}}
Phix does not have any specific support for AOP in either the language itself or its standard library and there appears to be little interest in adding any.
 
(that was my idea of a joke, btw, and not a dig at Go but just a childish and silly use of "translation of")
 
Actually, there is one way to instrument (specific) calls without modifying the existing code. Suppose you have somelib.e, containing:
<lang Phix>global procedure saysomething()
puts(1,"something\n")
end procedure</lang>
Then write wraplib.e as follows:
<lang Phix>include somelib.e as somelib
global procedure saysomething()
puts(1,"wrapthing\n")
somelib:saysomething()
puts(1,"thingwrap\n")
end procedure</lang>
And replace all (existing) "include somelib.e" with "include wraplib.e". Hopefully there will be (and usually there is) only one.
 
What this won't do is instrument internal calls to internal routines, at least not without modifying somelib.e, nor will it work for
things not in separate files, nor many of the builtins - specifically it should be possible for most of builtins\, but not possible
for any of builtins\VM\, though doubtless a few cross over.
 
Personally, while I'd begrudgingly accept that sort of thing for the occasional quick 'n dirty, I am strongly opposed to it being more
permanent: code should do what it says it does. For easy toggling, my own code tends to be littered with things like:
 
<lang Phix>global constant NEWFEATURE = true
...
if NEWFEATURE then ...</lang>
I also actually favour explicit shims, almost exactly what the task is asking for a way to avoid doing, such as
<lang Phix>function my_length(sequence s) return length(s) end function</lang>
and manually edit every single call, again so that any future (/temporary) changes are quick, easy & obvious.
 
=={{header|Python}}==
7,806

edits