Knowledge

Advice (programming)

Source 📝

382:, when a macro-like mechanism was provided to allow people to define their own rules for combining methods. Prior to that the rules governing combination of before/after methods and so-called whoppers methods (around) was fixed, and the compiler just generated the code for that. There were things called wrappers, which had macro-like behavior, but I forget when they came around. Traipsing through the various versions of MacLisp and Lispm manual to get this part of the history exactly right could be interesting. Or it could be that Howard Cannon or David Moon or someone could actually remember it all exactly. 265:
or the advice may change essential variables and continue with the computation so that the original procedure is executed, but with modified variables. Finally, the advice may not alter the execution or affect the original procedure at all, e.g., it may merely perform some additional computation such as printing a message or recording history. Since advice can be conditional, the decision as to what is to be done can depend on the results of the computation up to that point.
62:-addon makes extensive use of advice: it must modify thousands of existing Emacs modules and functions such that it can produce audio output for the blind corresponding to the visual presentation, but it would be infeasible to copy all of them and redefine them to produce audio output in addition to their normal outputs; so, the Emacspeak programmers define advice functions which run before and after. 581: 264:
Since each piece of advice is itself a procedure, it has its own entries and exits. In particular, this means that the execution of advice can cause the procedure that it modifies to be bypassed completely, e.g., by specifying as an exit from the advice one of the exits from the original procedure;
258:
Advising is the basic innovation in the model, and in the PILOT system. Advising consists of inserting new procedures at any or all of the entry or exit points to a particular procedure (or class of procedures). The procedures inserted are called "advice procedures" or simply
169:
developers and maintainers of Lisp packages and modules never use advice, since there is no advantage to be gained by advising functions when their original source definitions can be freely rewritten to include the desired features. Advice is only useful in that it enables
128:, lies in the fact that not only do the advised functions / methods not need to be designed to accept advice, but also the advice themselves need not be designed to be usable as advice - they're just normal functions. The availability of 148:
Advice has the potential to introduce confusion, as a piece of advice applied to a function is not apparent to a user who tracks down the function's source definition to learn about it. In such cases, advice acts almost like a
270:
The principal advantage of advising is that the user need not be concerned about the details of the actual changes in his program, nor the internal representation of advice. He can treat the procedure to be advised
275:, a single block, and make changes to it without concern for the particulars of this block. This may be contrasted with editing in which the programmer must be cognizant of the internal structure of the procedure. 517: 85:(the user's version is now out of sync with the core Emacs implementation, if it even works without further refactoring). What the user wants is quite simple — just to run another command any time 220:
Common Lisp implementations provide advice functionality (in addition to the standard method combination for CLOS) as extensions. LispWorks supports advising functions, macros and CLOS methods.
313:
Since method combination and macros are closely related, it's also interesting to note that the first macro system was described in 1963, three years before Warren Teitelman's PhD thesis.
140:
automatically into any other code in a variety of ways. Any piece of code can be advised to carry out any other computation before, after, around, or instead of its original definition.
55:
The practical use of advice functions is generally to modify or otherwise extend the behavior of functions which cannot or should not be readily modified or extended. For instance, the
510: 174:
users to subsequently modify default behaviour in a way that does not require propagation of such modifications into the core implementation's source definition.
503: 236: 463: 451: 631: 626: 332: 484: 369:. You could advise any function, just like in Interlisp at the time. The before/after ontology appeared separately in Flavors methods. 43:
which modify other functions when the latter are run; it is a certain function, method or procedure that is to be applied at a given
171: 194:
defined in a class, which were called before (respectively, after) member functions of the class. However, these were dropped from
636: 166: 295: 415: 545: 326: 120:
While this example is obviously trivial, the strength of advice, especially when compared to similar facilities such as
550: 526: 322: 303: 299: 121: 40: 28: 81:, copy it into their personal Emacs files, and add the desired functionality there, but this is tedious and, worse, 202: 464:
https://web.archive.org/web/20060913001624/http://www.ai.mit.edu/research/publications/browse/0000browse.shtml
452:
https://web.archive.org/web/20060913001624/http://www.ai.mit.edu/research/publications/browse/0600browse.shtml
133: 32: 560: 478: 82: 17: 73:
offers no such functionality, even if the corrected word appears frequently in the buffer. The user
224: 439: 378:
Method combination and macros were only marginally related until much later, in New Flavors and
65:
For a simple Emacs example: suppose after a user corrected a mis-spelled word using the Emacs
251: 137: 125: 490: 343: 240: 217:
methods, which are combined with the primary method under "standard method combination".
358: 183: 158: 620: 555: 366: 595: 419: 565: 495: 284: 44: 288: 56: 580: 570: 280: 254:
in his PhD thesis in 1966. Here is a quote from Chapter 3 of his thesis:
154: 150: 605: 600: 362: 66: 479:
Teitelman's PhD thesis, PILOT: A Step Toward Man-Computer Symbiosis
195: 59: 440:
LispWorks 7 User Guide and Reference Manual, The Advice Facility
379: 162: 129: 499: 165:. In practice, however, such issues rarely present themselves. 307: 310:. They were subsumed under the notion of method combination. 235:
The following is taken from a discussion at the mailing list
186:
in the late 1970s and early 1980s, namely functions called
69:
module, they wanted to re-spellcheck the entire buffer.
89:
runs. Using advice, it can be done as simply as this:
588: 533: 333:Aspect-oriented software development#Advice bodies 132:throughout the lifetime of a piece of code (cf. 223:EmacsLisp added advice-related code in version 511: 8: 518: 504: 496: 246:The term "advice" goes back to the term 395: 350: 18:Advice in aspect-oriented programming 7: 161:attendant to the extensive use of 25: 579: 403:The Design and Evolution of C++, 357:Advice appeared separately from 346:comments the above as follows: 182:A form of advices were part of 279:"Advising" found its way into 136:) in Lisp allows advice to be 1: 450:See, for example, AIM-602 at 77:track down the definition of 632:Lisp (programming language) 627:Aspect-oriented programming 551:Aspect-oriented programming 527:Aspect-oriented programming 243:contributed the following: 153:, a joke facility added to 653: 485:Interlisp reference manual 577: 294:It also found its way to 203:Common Lisp Object System 201:Advices are part of the 91: 416:"A Brief Guide to CLOS" 637:Programming constructs 561:Cross-cutting concerns 33:functional programming 39:describes a class of 491:"Origin of Advice" 323:Function decorator 614: 613: 250:as introduced by 159:spaghettification 122:Python decorators 16:(Redirected from 644: 583: 520: 513: 506: 497: 466: 460: 454: 448: 442: 437: 431: 430: 428: 427: 418:. Archived from 412: 406: 400: 383: 376: 370: 355: 252:Warren Teitelman 216: 212: 208: 193: 189: 126:Java annotations 116: 113: 110: 107: 104: 101: 98: 95: 88: 80: 72: 21: 652: 651: 647: 646: 645: 643: 642: 641: 617: 616: 615: 610: 584: 575: 529: 524: 475: 470: 469: 461: 457: 449: 445: 438: 434: 425: 423: 414: 413: 409: 401: 397: 392: 387: 386: 377: 373: 356: 352: 344:Gregor Kiczales 341: 319: 300:object-oriented 283:and later into 241:Pascal Costanza 233: 214: 210: 206: 191: 187: 180: 178:Implementations 146: 118: 117: 114: 112:flyspell-buffer 111: 108: 105: 102: 99: 96: 93: 86: 78: 70: 53: 23: 22: 15: 12: 11: 5: 650: 648: 640: 639: 634: 629: 619: 618: 612: 611: 609: 608: 603: 598: 592: 590: 586: 585: 578: 576: 574: 573: 568: 563: 558: 553: 548: 543: 537: 535: 531: 530: 525: 523: 522: 515: 508: 500: 494: 493: 488: 482: 474: 473:External links 471: 468: 467: 462:See AIM-57 at 455: 443: 432: 407: 394: 393: 391: 388: 385: 384: 371: 349: 348: 340: 337: 336: 335: 330: 318: 315: 277: 276: 268: 266: 262: 260: 232: 229: 184:C with Classes 179: 176: 145: 142: 92: 52: 49: 47:of a program. 24: 14: 13: 10: 9: 6: 4: 3: 2: 649: 638: 635: 633: 630: 628: 625: 624: 622: 607: 604: 602: 599: 597: 594: 593: 591: 587: 582: 572: 569: 567: 564: 562: 559: 557: 556:Aspect weaver 554: 552: 549: 547: 544: 542: 539: 538: 536: 532: 528: 521: 516: 514: 509: 507: 502: 501: 498: 492: 489: 486: 483: 480: 477: 476: 472: 465: 459: 456: 453: 447: 444: 441: 436: 433: 422:on 2015-05-06 421: 417: 411: 408: 404: 399: 396: 389: 381: 375: 372: 368: 364: 360: 354: 351: 347: 345: 338: 334: 331: 328: 324: 321: 320: 316: 314: 311: 309: 306:developed at 305: 302:extension to 301: 297: 292: 290: 286: 282: 274: 269: 267: 263: 261: 257: 256: 255: 253: 249: 244: 242: 238: 230: 228: 226: 221: 218: 204: 199: 197: 185: 177: 175: 173: 168: 164: 160: 157:to spoof the 156: 152: 143: 141: 139: 135: 131: 127: 123: 90: 84: 76: 68: 63: 61: 58: 50: 48: 46: 42: 38: 34: 30: 19: 540: 458: 446: 435: 424:. Retrieved 420:the original 410: 402: 398: 374: 367:Lisp Machine 353: 342: 312: 298:, the first 293: 278: 272: 247: 245: 237:aosd-discuss 234: 222: 219: 200: 181: 147: 134:code staging 119: 74: 64: 54: 36: 26: 606:AspectWerkz 205:(CLOS), as 144:Readability 103:ispell-word 87:ispell-word 79:ispell-word 71:ispell-word 621:Categories 566:Join point 481:(AITR-221) 426:2015-04-27 390:References 285:Xerox PARC 172:downstream 130:evaluation 97:advice-add 45:join point 596:AspectC++ 589:Languages 487:from 1974 289:Interlisp 273:as a unit 259:"advice". 57:Emacspeak 41:functions 571:Pointcut 534:Concepts 365:and the 325:(w.r.t. 317:See also 281:BBN Lisp 248:advising 227:, 1994. 167:Upstream 155:INTERCAL 151:COMEFROM 601:AspectJ 363:Maclisp 359:Flavors 296:Flavors 231:History 215::around 207::before 138:inlined 83:brittle 546:Aspect 541:Advice 327:Python 213:, and 211::after 192:return 109:#' 106::after 100:#' 67:ispell 37:advice 29:aspect 405:p. 57 339:Notes 225:19.28 163:GOTOs 75:could 60:Emacs 380:CLOS 304:Lisp 190:and 188:call 124:and 31:and 361:in 308:MIT 287:'s 196:C++ 51:Use 35:, 27:In 623:: 291:. 239:. 209:, 198:. 519:e 512:t 505:v 429:. 329:) 115:) 94:( 20:)

Index

Advice in aspect-oriented programming
aspect
functional programming
functions
join point
Emacspeak
Emacs
ispell
brittle
Python decorators
Java annotations
evaluation
code staging
inlined
COMEFROM
INTERCAL
spaghettification
GOTOs
Upstream
downstream
C with Classes
C++
Common Lisp Object System
19.28
aosd-discuss
Pascal Costanza
Warren Teitelman
BBN Lisp
Xerox PARC
Interlisp

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.