Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with alexandria:curry and alexandria:rcurry #552

Open
bohonghuang opened this issue Feb 11, 2023 · 0 comments
Open

Problems with alexandria:curry and alexandria:rcurry #552

bohonghuang opened this issue Feb 11, 2023 · 0 comments

Comments

@bohonghuang
Copy link

Eval this in REPL:

(ql:quickload :alexandria)

(compile
 (defun next (predicate generator)
   (multiple-value-bind (value present-p) (funcall generator)
     (loop :until (funcall predicate value)
           :do (setf (values value present-p) (funcall generator)))
     (values value present-p))))

(next (alexandria:rcurry #'>= 3) (let ((i 0))
                                 (lambda ()
                                   (if (<= (incf i) 5)
                                       (values i t)
                                       (values nil nil)))))

which is expected to output 3, T, but on ABCL it will cause:

The value T is not of type REAL.
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLY interactive evaluation request.
 1: [*ABORT] Return to SLY's top level.
 2: [ABORT] Abort thread.

Backtrace:
 0: (INVOKE-DEBUGGER #<TYPE-ERROR {24998C06}>)
 1: org.armedbear.lisp.Lisp.error(Lisp.java:383)
 2: org.armedbear.lisp.Lisp.type_error(Lisp.java:457)
 3: (#<LOCAL-FUNCTION IN RCURRY {2A5E76E5}> 2)
 4: (NEXT #<LOCAL-FUNCTION IN RCURRY {2A5E76E5}> #<ANONYMOUS-INTERPRETED-FUNCTION {2E61E776}>)
 5: (SYSTEM::%EVAL (NEXT (ALEXANDRIA:RCURRY #'>= 3) ..))
 6: (EVAL (NEXT (ALEXANDRIA:RCURRY #'>= 3) ..))
 7: (#<LOCAL-FUNCTION IN INTERACTIVE-EVAL {6B637CDE}>)

This error will not occur if:

  1. Call the next function without compiling it.
  2. Or substitute (alexandria:rcurry #'>= 3) with (lambda (x) (>= x 3)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant