6

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.

3 Answers 3

4

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I've put in a :use at the beginning of my file, but it fails to compile and gives a warning that the package "also exports the following symbols: (preprocess-clause define-clause config2 ...)" and a huge list of symbols. At the beginning of my file, I have (defpackage :foo (:use :cl :iterate)) (in-package :foo). All of the documentation I've read about this seems to indicate this should work, but it doesn't for some reason.
2

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.

Comments

1

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.