wbooze

debugger error

Oct 13th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. (defclass standard-point ()
  2. ((x :initform 0 :initarg :x)
  3. (y :initform 0 :initarg :y)))
  4.  
  5.  
  6. (defgeneric distance-origin (point))
  7.  
  8. (defmethod distance-origin ((point1 standard-point))
  9. (when (and (slot-exists-p point1 'x) (slot-exists-p point1 'y))
  10. (sqrt (+ (expt (sb-mop:standard-instance-access point1 0) 2)
  11. (expt (sb-mop:standard-instance-access point1 1) 2)))))
  12.  
  13. (defgeneric distance (point1 &optional point2))
  14.  
  15. (defmethod distance (point1 &optional point2))
  16.  
  17. (defmethod distance ((point1 standard-point) &optional point2)
  18. (when (and (slot-exists-p point1 'x) (slot-exists-p point1 'y))
  19. (sqrt (+ (expt (sb-mop:standard-instance-access point1 0) 2)
  20. (expt (sb-mop:standard-instance-access point1 1) 2)))))
  21.  
  22. (defmethod distance ((point1 standard-point) &optional (point2 standard-point))
  23. (when (and (slot-exists-p point1 'x) (slot-exists-p point1 'y)
  24. (slot-exists-p point2 'x) (slot-exists-p point2 'y))
  25. (sqrt (+ (expt (- (sb-mop:standard-instance-access point2 0) (sb-mop:standard-instance-access point1 0)) 2)
  26. (expt (- (sb-mop:standard-instance-access point2 1) (sb-mop:standard-instance-access point1 1)) 2)))))
  27.  
  28. (defvar p1 (make-instance 'standard-point :x -3 :y 5))
  29. (defvar p2 (make-instance 'standard-point :x 7 :y -1))
  30.  
  31. (defun test ()
  32. (distance p2 p1))
  33.  
  34. (test)
  35.  
  36.  
  37. ; in: DEFMETHOD DISTANCE (T)
  38. ; (DEFMETHOD DISTANCE (POINT1 &OPTIONAL POINT2))
  39. ; --> LET* SB-INT:NAMED-LAMBDA
  40. ; ==>
  41. ; #'(SB-INT:NAMED-LAMBDA (SB-PCL::FAST-METHOD DISTANCE (T))
  42. ; (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. POINT1 &OPTIONAL POINT2)
  43. ; (DECLARE (IGNORABLE SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL.)
  44. ; (DISABLE-PACKAGE-LOCKS SB-PCL::PV-ENV-ENVIRONMENT))
  45. ; (DECLARE (SB-PCL::%PARAMETER POINT1))
  46. ; (DECLARE (TYPE T POINT1))
  47. ; (DECLARE (IGNORABLE POINT1))
  48. ; (SYMBOL-MACROLET ((SB-PCL::PV-ENV-ENVIRONMENT SB-PCL::DEFAULT))
  49. ; (SB-PCL::FAST-LEXICAL-METHOD-FUNCTIONS ((POINT1)
  50. ; SB-PCL::.NEXT-METHOD-CALL.
  51. ; (POINT1) NIL
  52. ; :CALL-NEXT-METHOD-P NIL :SETQ-P
  53. ; NIL :PARAMETERS-SETQD NIL
  54. ; :METHOD-CELL (#:METHOD-CELL)
  55. ; ...)
  56. ; (LOCALLY
  57. ; (DECLARE #)
  58. ; (SYMBOL-MACROLET #
  59. ; #
  60. ; #)))))
  61. ;
  62. ; caught STYLE-WARNING:
  63. ; The variable POINT2 is defined but never used.
  64. ;
  65. ; compilation unit finished
  66. ; caught 1 STYLE-WARNING condition
  67.  
  68. ; file: /home/oleo/lisp/clos/packages-and-classes/standard-slot-order.lisp
  69. ; in: DEFMETHOD DISTANCE (STANDARD-POINT)
  70. ; (DEFMETHOD DISTANCE ((POINT1 STANDARD-POINT) &OPTIONAL POINT2)
  71. ; (WHEN (AND (SLOT-EXISTS-P POINT1 'X) (SLOT-EXISTS-P POINT1 'Y))
  72. ; (SQRT (+ (EXPT # 2) (EXPT # 2)))))
  73. ; --> LET* SB-INT:NAMED-LAMBDA
  74. ; ==>
  75. ; #'(SB-INT:NAMED-LAMBDA (SB-PCL::FAST-METHOD DISTANCE (STANDARD-POINT))
  76. ; (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. POINT1 &OPTIONAL POINT2)
  77. ; (DECLARE (IGNORABLE SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL.)
  78. ; (DISABLE-PACKAGE-LOCKS SB-PCL::PV-ENV-ENVIRONMENT))
  79. ; (DECLARE (SB-PCL::%PARAMETER POINT1))
  80. ; (DECLARE (IGNORABLE POINT1))
  81. ; (SYMBOL-MACROLET ((SB-PCL::PV-ENV-ENVIRONMENT SB-PCL::DEFAULT))
  82. ; (SB-PCL::FAST-LEXICAL-METHOD-FUNCTIONS ((POINT1)
  83. ; SB-PCL::.NEXT-METHOD-CALL.
  84. ; (POINT1) NIL
  85. ; :CALL-NEXT-METHOD-P NIL :SETQ-P
  86. ; NIL :PARAMETERS-SETQD NIL
  87. ; :METHOD-CELL (#:METHOD-CELL)
  88. ; ...)
  89. ; (DECLARE (SB-PCL::%CLASS POINT1 STANDARD-POINT))
  90. ; (LOCALLY
  91. ; (DECLARE #)
  92. ; (SYMBOL-MACROLET #
  93. ; #
  94. ; #)))))
  95. ;
  96. ; caught STYLE-WARNING:
  97. ; The variable POINT2 is defined but never used.
  98. ;
  99. ; compilation unit finished
  100. ; caught 1 STYLE-WARNING condition
  101.  
  102. ; file: /home/oleo/lisp/clos/packages-and-classes/standard-slot-order.lisp
  103. ; in: DEFMETHOD DISTANCE (STANDARD-POINT)
  104. ; (DEFMETHOD DISTANCE
  105. ; ((POINT1 STANDARD-POINT) &OPTIONAL (POINT2 STANDARD-POINT))
  106. ; (WHEN
  107. ; (AND (SLOT-EXISTS-P POINT1 'X) (SLOT-EXISTS-P POINT1 'Y)
  108. ; (SLOT-EXISTS-P POINT2 'X) (SLOT-EXISTS-P POINT2 'Y))
  109. ; (SQRT (+ (EXPT # 2) (EXPT # 2)))))
  110. ; --> LET* SB-INT:NAMED-LAMBDA FUNCTION
  111. ; ==>
  112. ; (LET ((#:G1 STANDARD-POINT))
  113. ; (LOCALLY
  114. ; (DECLARE (MUFFLE-CONDITIONS CODE-DELETION-NOTE))
  115. ; (SB-C::%FUNCALL #'(FAST-METHOD DISTANCE (STANDARD-POINT)) SB-PCL::.PV.
  116. ; SB-PCL::.NEXT-METHOD-CALL. POINT1 #:G1)))
  117. ;
  118. ; caught WARNING:
  119. ; undefined variable: COMMON-LISP-USER::STANDARD-POINT
  120. ;
  121. ; compilation unit finished
  122. ; Undefined variable:
  123. ; STANDARD-POINT
  124. ; caught 1 WARNING condition
  125. T
  126. *
  127.  
  128. * (distance p1)
  129.  
  130. debugger invoked on a UNBOUND-VARIABLE in thread
  131. #<THREAD "main thread" RUNNING {1000560083}>:
  132. The variable STANDARD-POINT is unbound.
  133.  
  134. Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
  135.  
  136. restarts (invokable by number or by possibly-abbreviated name):
  137. 0: [CONTINUE ] Retry using STANDARD-POINT.
  138. 1: [USE-VALUE ] Use specified value.
  139. 2: [STORE-VALUE] Set specified value and use it.
  140. 3: [ABORT ] Exit debugger, returning to top level.
  141.  
  142. ((:METHOD DISTANCE (STANDARD-POINT)) #<STANDARD-POINT {1001AB66F3}>) [fast-method,optional]
  143. source: (DEFMETHOD DISTANCE
  144. ((POINT1 STANDARD-POINT)
  145. &OPTIONAL (POINT2 STANDARD-POINT))
  146. (WHEN
  147. (AND (SLOT-EXISTS-P POINT1 'X) (SLOT-EXISTS-P POINT1 'Y)
  148. (SLOT-EXISTS-P POINT2 'X) (SLOT-EXISTS-P POINT2 'Y))
  149. (SQRT (+ (EXPT (- # #) 2) (EXPT (- # #) 2)))))
  150. 0]
  151.  
  152.  
Add Comment
Please, Sign In to add comment