home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / mcl / 1964 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.9 KB  |  66 lines

  1. Path: sparky!uunet!olivea!apple!goofy!cambridge.apple.com!oddmund@idt.unit.no
  2. From: oddmund@idt.unit.no
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Correct to  ignore params to :around methods?
  5. Message-ID: <199301091950.AA03118@sigyn.idt.unit.no>
  6. Date: 9 Jan 93 19:50:55 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 55
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11.  
  12. I use :around methods to bind special variables and then
  13. call call-next-method with no parameters.
  14.  
  15. This works, but causes compiler warnings for each non-
  16. specialized parameter.
  17.  
  18. I can get rid of the warnings by declaring to ignore 
  19. the parameters, but I feel uncomfortable doing that since 
  20. the parameters are in fact "used" by the method called 
  21. by call-next-method. Ignoring them works, but would it 
  22. work if my declaration were trusted?
  23.  
  24. What is the correct way to handle this? 
  25. Thanks for any assistance.
  26.  
  27. Oddmund Mogedal
  28. oddmund@idt.unit.no
  29.  
  30. ******
  31. Here is an example:
  32.  
  33. (defvar *test* 0)
  34.  
  35. (defclass test-class ()
  36.   ((first-slot :accessor first-slot)))
  37.  
  38. ; a perfectly useless method, but that isn't the point
  39. (defmethod set-first-slot ((obj test-class) 
  40.                            new-value)
  41.   (setf (first-slot obj) 
  42.         (+ *test* new-value)))
  43.  
  44. (defclass test-class-sub (test-class)
  45.   ())
  46.  
  47. ;Evaluating the :around method below causes the
  48. ;following compiler warning:
  49. ;Compiler warnings :
  50. ;   Unused lexical variable NEW-VALUE, in SET-FIRST-SLOT.
  51. (defmethod set-first-slot :around ((obj test-class-sub) 
  52.                                    new-value)
  53.   (let ((*test* 24))
  54.     (call-next-method)))
  55.  
  56. #|
  57. ;The following version gets rid of the warning, but is it
  58. ;correct (i.e. would it be correct if my declaration were
  59. ;trusted):
  60. (defmethod set-first-slot :around ((obj test-class-sub) 
  61.                                    new-value)
  62.   (declare (ignore new-value))
  63.   (let ((*test* 24))
  64.     (call-next-method)))
  65. |#
  66.