(I'm a lurker, hoping to have more time to participate.)

Jordi - IlMaestro - Ministral writes:
 > Well yes if any of my computer engineering teachers could see that
 > code, they'd throw me through the window. If I had come up with a
 > better idea, then I would have chosen that one. The fact here was
 > that we needed to add functionalities to certain pieces of code
 > depending on what was loaded. However, it is simply intended to add
 > lines of code ( typically function calls ) to an already defined
 > method. I don't provide this as a generic coding practice, nor expect
 > people to start modifying ifs statements on the fly depending on what
 > browser you're using. Then it will become a nightmare.

The discussion on adding functionality to a method reminded me
of the "advice" feature that many Lisp languages have (we can learn a
lot from Lisp).  Here is the description of the ad-add-advice function
in Emacs Lisp.


   `ad-add-advice' is a compiled Lisp function
     -- loaded from "advice"
   (ad-add-advice FUNCTION ADVICE CLASS POSITION)
   
   Documentation:
   Adds a piece of ADVICE to FUNCTION's list of advices in CLASS.
   If FUNCTION already has one or more pieces of advice of the specified
   CLASS then POSITION determines where the new piece will go.  The value
   of POSITION can either be `first', `last' or a number where 0 corresponds
   to `first'.  Numbers outside the range will be mapped to the closest
   extreme position.  If there was already a piece of ADVICE with the same
   name, then the position argument will be ignored and the old advice
   will be overwritten with the new one.

       If the FUNCTION was not advised already, then its advice info
   will be initialized.  Redefining a piece of advice whose name is part
   of the cache-id will clear the cache.


 > This function, being as dangerous as it is, if used with common sense
 > allows to get rid of all those anoying additons that check for a
 > module being loaded. 

I agree that this is a desirable feature.  What you did seems not all
that different from Lisp's advice, so you should be pleased.  The fact
that it still raises hackles should suggest that there is still a better
way to do it while maintaining the desired optionality and separation of
control (i.e. no embedded if's).  I don't like the numeric ordering, but
I can't think how to do it better at the moment (something about
dependencies).

-- 
Daniel LaLiberte
[EMAIL PROTECTED]
http://www.HoloNexus.org/~liberte/
http://www.HyperNews.org/~liberte/

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to