This is mostly for the record, as I'm afraid I don't have any fix yet...

2008/8/12 Neil Jerram <[EMAIL PROTECTED]>:
> 2008/8/11 Bill Schottstaedt <[EMAIL PROTECTED]>:
>> guile> (< 1.0+1.0i)
>> #t

> My guess (without actually looking at the code) is that

> - the single arg case is being optimized before reaching the check for
> a complex number.

My guess was correct.  This comes from < being implemented as a
scm_tc7_rpsubr, which means that there is an underlying C primitive
(scm_less_p) that takes 2 args, and the evaluator deals with calling
this however many times are needed.  When there's just 1 arg, the
evaluator shortcuts the process and returns #t.

Instead of just returning #t, I guess there should be a type predicate
call.  It's not obvious where one would store the type predicate
though, in the subr structure...

As a workaround, you could use:

(let ((libguile-< <))
  (set! < (lambda args
            (or (null? args)
                (not (null? (cdr args)))
                (real? (car args))
                (error "wrong type arg" (car args)))
            (apply libguile-< args))))

Would that help?

Regards,
     Neil


Reply via email to