[Openmcl-devel] Shortcircuiting of argument evaluation in #'<

Ron Garret ron at flownet.com
Wed Jan 9 07:35:14 PST 2013


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.

rg

On Jan 9, 2013, at 4:44 AM, Eric Marsden wrote:

> Hi,
> 
> The function < is shortcircuiting the evaluation of its arguments, which
> from my reading of CLHS (3.1.2.1.2.3 Function Forms) is not allowed (my
> understanding is that it's allowed for special forms/macros, but not for
> functions).
> 
> 
> ,----
> | Welcome to Clozure Common Lisp Version 1.9-dev-r15573M  (LinuxX8664)!
> | ? (defun foo (a)
> |     (if (< 3 2 (setq a -1)) a a))
> | FOO
> | ? (foo 1)
> | 1   ;; expecting -1
> `----
> 
> -- 
> Eric Marsden
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list