[Bese-devel] Re: UCW box-set - undefined-function error

Marco Baringer mb at bese.it
Fri Jun 16 08:06:00 UTC 2006


"Tom Popovich" <tpop.news at gmail.com> writes:

> I will post the changes to the forum. ?? what is the best way to submit code?  
> I tried to email a uuencoded gzip compressed file previously but that
> did easily make it to the web site.

if possible the best thing is a darcs patch.

> Details:
>
> == (1) ==
>
> I had some trouble w/  package names & I developed a nice soln to always use
> symbol name.  It works.
> BUT for some crazy reason (unknown to me) I had to stick
> string-2-function-symbol-name   and string-2- package-symbol-name it in the CL
> package to get it to work.  Otherwise I got  "unbound fnct" errors in  the
> split-sequence.lisp file.
>
> (which is what I did) See end of this email for code:
>
>
> I defined a new macro defpackage2 that automatically converts string forms to
> symbols.

the 'solution' to this is to fix the defpackage form:

(defpackage :split-sequenc
  (:use #:common-lisp)
  (:nicknames #:partition)
  (:export #:split-sequence
           #:split-sequence-if
           #:split-sequence-if-not
           #:partition
           #:partition-if
           #:partition-if-not))

this will work on both ansi and modern lisps and is 100% standard
code.

> == (2) ==
>
> I had to hand eval the with-unique-names macro when lisp was in a error break:
> ( its definition is shown below   ??? for some reason it thinks that its not
> defined in the package yet its there near the top of the file that is being
> compiled???)

what happens when compiling a file:

loop
  for form = (read-next-form-from-file)
  until (no-more-forms-in-file)
  if (eval-time-of-form-is-:compile-toplevel)
    do (eval form)
  else
    do (compile (MACROEXPAND form))

the idea is that macroexpansion is performed at compile time,
macroexpansion requires running user code. let's say you have this
file:

------------------------------------------------------------------------
(defun foo ()
  (bar))

(defmacro bar ()
  `(stuff))
------------------------------------------------------------------------

even though bar is in the same file as foo the definiton of bar is not
noticed until after foo has been compilied, however in order to
compile foo we need the definiton of bar ... boom!

generally the solution to this is to wrap the problematic forms in

(eval-when (:compile-toplevel :load-toplevel :execute)
  ...)

[note: there's an eval-always macro in arnesi which makes that easier
to write, but i'm going to stick with ansi lisp here]

this ensure that the various definitions are available eariel enough.

now, im not 100% certain this is your problem, but could you try and
see what happens?

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen




More information about the bese-devel mailing list