Question

When I load the "iterate" package using Quicklisp ( (ql:quickload "iterate") ), it seems to load fine but none of the functions really work. When I enter (iterate:iter (for i from 0 to 10) (collect i)), I get an error saying "The variable I is unbound" and several style warnings saying that COLLECT and FOR are undefined functions and FROM is an undefined variable. The same thing happens if I try to use ITER or ITERATE instead of ITERATE:ITER. I'm using SBCL.

Was it helpful?

Solution

The "operators" of the clauses also reside in the iterate package:

(iterate:iter (iterate:for i from 1 to 10) (iterate:collect i))

Iterate is a package that is often convenient to use-package (or :use in the package definition).

OTHER TIPS

This isn't a working solution, but I am very curious to find one myself, so, perhaps someone will hep me too :)

(defun old-package () (package-name *package*))

(defmacro i++ (&body body)
  (let ((old (package-name *package*))
        (new (package-name (find-package 'iterate))))
    (in-package #.(package-name (find-package 'iterate)))
    (prog1
        `(unwind-protect
              (progn
                (in-package ,new)
                (iter ,@body))
           (in-package ,old))
      (in-package #.(old-package)))))

Now, this won't work because the symbols of the body are getting defined in the old (cl-user for example) package and then once you try to use them in iterate package it all breaks. But there has to be some way... beside replacing all symbols potentially in iterate package...

defining it as part of the package with :use is probably the best way style-wise, but I just used

(use-package "ITERATE")

and it seemed to work just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top