[Openmcl-devel] Shortcircuiting of argument evaluation in #'<
Pascal J. Bourguignon
pjb at informatimago.com
Wed Jan 9 11:04:49 PST 2013
Ron Garret <ron at flownet.com> writes:
> IMO this is a bug in the spec, not CCL. (< a b c ...) ought to mean
> (and (< a b) (< b c) ...) , not (let* ((a_ a) (b_ b) ...) (< a_ b_ c_
> ...)). Putting side-effecting code inside a comparison operator is a
> Truly Horrible Idea (which is even worse than the previously
> trademarked Really Bad Idea) and any programmer who wants to write
> code that relies on it ought to bear the burden of expanding his code
> into the corresponding LET* rather than impose the burden of running
> dead code on the entire extant code base. That is too high a price to
> pay. The spec is not scripture.
What prevents you to write either:
(defmacro lt (&rest args)
`(and ,@(loop for (a b) on args while b collect `(< ,a ,b))))
(lt 1 0 (error "Duh!"))
or
(shadow '<)
(defmacro < (&rest args)
`(and ,@(loop for (a b) on args while b collect `(cl:< ,a ,b))))
(< 1 0 (error "Double-Duh!"))
?
The spec is the scripture, by definition.
Happily:
1- you can write your own packages using your own packages (shadow,
use-package, etc).
2- an implementer can define a subset of Common Lisp.
3- an implementer can define a superset of Common Lisp.
4- an implementer can define a different lisp than Common Lisp.
5- a user can use a different lisp than Common Lisp. Good luck building
the network effect that may be wanted. (Clojure seems to be able to
do so, so it's not impossible).
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
More information about the Openmcl-devel
mailing list