Subject: Re: MACROS : now i see the power !
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 23 Mar 2004 11:58:43 -0600
Newsgroups: comp.lang.lisp
Message-ID: <DHWdnZpxzYtO5_3d3czS-g@speakeasy.net>
Christophe Turle  <cturle@nospam.fr> wrote:
+---------------
| Example : You will gain lots of time teaching your system that (and (> x
| y) (<= x y)) is always false. This is meta-knowledge. And macros allow
| you to implement this knowledge. Imagine f is a very expensive function.
| 
| (macroexpand-1 '(and+ (<= (f) 1) (> (f) 1)))
| => nil ; so (f) will never be evaluated !!!
+---------------

CAREFUL!! Doing this sort of optimization correctly is harder
than it initially appears. What if F is stateful, or does I/O,
or is in *ANY* way not purely functional? Then you've broken
the semantics!!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607