[Openmcl-devel] with-package

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sat Jan 12 17:51:41 PST 2013

replace with-package by the following:

(defmacro with-package ((&rest names) &body body)
  (let ((r (gensym)) (e (gensym)))
       (use , at names)
       (multiple-value-bind (,r ,e)
              (eval (read-from-string
                     (format nil "(progn ~{~S ~})"
                             (let ((*readtable* (copy-readtable)))
                               (set-macro-character #\(
                                                    (lambda (stream char)
                                                      (declare (ignore
#\" nil)
                                                      (let ((str "") (n 0)
(within-string nil) (pc nil))
                                                        (do ((c (read-char
stream t nil t) (read-char stream t nil t)))
                                                            ((and (= n 0)
(eq c #\))))
                                                          (if (not
                                                              (if (eq c #\()
                                                                  (incf n)
                                                                  (if (eq c
                                                          (if (and (not (eq
pc #\\)) (eq c #\"))
within-string (not within-string))
                                                                (setf str
(format nil "~A\"" str)))
                                                              (setf str
(format nil "~A~A" str c)))
                                                          (setf pc c))
         (unuse ,@(reverse names))
         (if (null ,e)
             (values-list ,r)
             (error (format nil "~S" ,e)))))))

? (with-package (calculus) (print "-:(") (print "success\"full"))




On Sat, Jan 12, 2013 at 11:59 PM, Pascal J. Bourguignon <
pjb at informatimago.com> wrote:

> Taoufik Dachraoui <dachraoui.taoufik at gmail.com> writes:
> > I managed to write a correct version of with-package macro, this is
> > due to the valuable hints and discussions, I learned a lot by being a
> > member of ccl thank you a lot for all your helps
> >
> > here is the whole code of the mb simple file system (some bugs may be
> > found sorry i did not test thoroughly)
> >
> > Now I would like to see why this design is wrong by showing me
> > examples where the system can fail
>     cl-user> (mb:with-package (MB)
>               (print ":-(")
>               (print "fails badly"))
>     > Debug: #<end-of-file #x302001D88FAD>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130113/06badd71/attachment.htm>

More information about the Openmcl-devel mailing list