You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a continuation of the work on issue #609. To evaluate the compatibility of Medley Common Lisp with ANSI Common Lisp I'm testing on Medley the code of the book Practical Common Lisp by Peter Seibel.
Session transcript
To test the code of chapter 16 I evaluated the expressions at a XCL Exec. I added only a few of the missing definitions and calls as some are in the next chapter and I'll get to them anyway.
All the code seems to work as expected:
2/8> (defgenericdraw (shape)
(:documentation"Draw the given shape on the screen."))
DRAW
2/9>
2/9> (defclassbank-account ()
((customer-name
:initarg:customer-name)
(balance
:accessor balance
:initarg:balance:initform0)))
BANK-ACCOUNT
2/10>
2/10> (defparameter*account*
(make-instance'bank-account :customer-name"John Doe":balance1000))
*ACCOUNT*
2/11>
2/11> (defgenericwithdraw (account amount)
(:documentation"Withdraw the specified amount from the account.Signal an error if the current balance is less than amount."))
WITHDRAW
2/12>
2/12> (defmethodwithdraw ((account bank-account) amount)
(when (< (balance account) amount)
(error"Account overdrawn."))
(decf (balance account) amount))
(WITHDRAW (BANK-ACCOUNT))
2/13>
2/13> (withdraw *account*100)
900
2/14>
2/14> (withdraw *account*1100)
Account overdrawn.
2/15>
2/15> (defgenericpriority (job)
(:documentation"Return the priority at which the job should be run.")
(:method-combination+))
PRIORITY
2/16>
2/16> (defgenericpriority (job)
(:documentation"Return the priority at which the job should be run.")
(:method-combination+:most-specific-last))
New GENERIC-FUNCTIONS definition for PRIORITY.
PRIORITY
2/17>
2/17> (defgenericbeat (drum stick)
(:documentation"Produce a sound by hitting the given drum with the given stick."))
BEAT
2/18>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Chapter 16. Object Reorientation: Generic Functions
This is a continuation of the work on issue #609. To evaluate the compatibility of Medley Common Lisp with ANSI Common Lisp I'm testing on Medley the code of the book Practical Common Lisp by Peter Seibel.
Session transcript
To test the code of chapter 16 I evaluated the expressions at a XCL Exec. I added only a few of the missing definitions and calls as some are in the next chapter and I'll get to them anyway.
All the code seems to work as expected:
Beta Was this translation helpful? Give feedback.
All reactions