From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.bredband.com!bredband!news01.chello.se!news01.chello.no!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: cond-let-p References: Mail-Copies-To: never From: Erik Naggum Message-ID: <3222683933311432@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 14 Feb 2002 13:58:51 GMT X-Complaints-To: abuse@chello.no X-Trace: news01.chello.no 1013695131 212.186.234.171 (Thu, 14 Feb 2002 14:58:51 MET) NNTP-Posting-Date: Thu, 14 Feb 2002 14:58:51 MET X-Received-Date: Thu, 14 Feb 2002 14:59:01 MET (news01.chello.no) Xref: archiver1.google.com comp.lang.lisp:26517 * Manuel Giraud | Is there in CL a form that let you do stuff like that : | | (cond-let ((a (func)) (* a a)) | (t (error "meuh"))) | | Where a clause is accepted if (func) returns a non-nil value and then 'a' | is bound to this value in the remaining consequent. You are probably aware of the ugly Scheme hack with -> to pass the result of the expression to a function in the body. I toyed with a funcond (hybrid of funcall and cond) once that went like this: (funcond ((func) (lambda (x) (* x x))) (t (lambda (x) (declare (ignore x)) (error "meuh")))) For fairly obvious reasons, I dropped this, having learned something about language design. The not too infrequently used way to do this, however, goes like this: (let (x) (cond ((setq x (func)) (* x x)) (t (error "meuh")))) Which is probably a macro should do if you do not like to see it directly in your own code. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief.