Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Method specialization style question
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cliff Crawford  
View profile  
 More options Mar 27 2004, 3:34 pm
Newsgroups: comp.lang.lisp
From: Cliff Crawford <cj...@cornell.edu>
Date: Sat, 27 Mar 2004 20:34:47 GMT
Local: Sat, Mar 27 2004 3:34 pm
Subject: Re: Method specialization style question
On 2004-03-26, Peter Seibel <pe...@javamonkey.com> wrote:
|
|  Anyone have any stylistic preference for one or the other? (I guess
|  the practical difference is just trading a type-error in for a
|  no-applicable-method error if withdraw is ever called with a
|  non-numeric second argument.)

A third possibility would be to use CHECK-TYPE:

(defmethod withdraw ((account account) amount)
  (check-type amount number)
  (if (>= (balance account) amount)
    (decf (balance amount) amount)
    (error "Insufficient funds.")))

Now if you call WITHDRAW with a non-numeric AMOUNT, the debugger will
give you an opportunity to change it (via the STORE-VALUE restart).

--
 Cliff Crawford             ***             cj...@cornell.edu

"The perfection of art is to conceal art."      -- Quintilian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.