Arc Forumnew | comments | leaders | submitlogin
(updated) extend: Conditionally extend a function (awwx.ws)
4 points by aw 5665 days ago | 1 comment


2 points by aw 5665 days ago | link

This is an updated version of my extend macro.

- I found I never used the label feature, so I dropped it.

- I noticed that I was often repeating the argument list in the test and in the body, so the test and body are now implicitly wrapped in a fn and the one argument list is used for both.

- Sometimes I need to use the value of the test expression in the body, so the value returned by the test expression is now available in the body as it.

- I haven't used this yet so maybe I don't need it, but inspired by redef in Anarki the original function is now available in the body as orig.

I use extend when I need to conditionally redefine a function based on a specific test that I'm applying to the arguments. For other kinds of redefinitions, you may want to use redef or some other method.

-----