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

Tom Popovich tpop.news at gmail.com
Fri Jun 16 01:09:28 UTC 2006


|| > WHAT LISP:  I was using Allegro version 8.0 on Windows (modern image
|| > version - the one w/ case sensitive symbol names) - its called
mlisp.exe
|| > they also have alisp.exe that uppercases all symbol names.
|| [snip]
||
|| I'm 90% sure this is the problem: the hash table's getters/setters are
dynamically created
|| with uppercase letters, yet when they are invoked they use lowercase
letters.
|| This is fine for ansi cl, but not so much for "modern" versions of lisp.
||
|| Use the ansi version of allegro (alisp) and I think that solves this
problem.


Thanks again Lou!
For alisp.exe, I fixed some key  upper -vs- lower case symbol problems.
I had started replacing depackage import/uses using  defpackage2 (which I
thought I'd have to replace everywhere but so far I've only changed one file
- split-sequence.lisp ).

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.

 now have loaded " start.lisp" (at least the load now returns true!)    And
I can click on *http://127.0.0.1:8080/ * <http://127.0.0.1:8080/> and see
the demos. I have a problem w/ dynamic form demo which blows up.
 The other demos seem to work.

*I needed to fix 2** areas* *:*

*(1)* package names == sol ved with coming up w/ a new  defpackage2  macro

*(2)* with-unique-names macro from package :it.bese.arnesi is never found
<here I just hacked it by choose a restart to use the fnct w/ that name in a
different package>

<my code is as follows for creating defpackage2 >


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

Idea is to easily map:

(defpackage2 :split-sequence

  (:use "cl")

  (:nicknames "partition")

  (:export "split-sequence" "split-sequence-if" "split-sequence-if-not"

           "partition" "partition-if" "partition-if-not"))

to:

(defpackage :split-sequence

  (:USE :CL)

  (:NICKNAMES :PARTITION)

  (:EXPORT #:SPLIT-SEQUENCE #:SPLIT-SEQUENCE-IF #:SPLIT-SEQUENCE-IF-NOT
#:PARTITION #:PARTITION-IF #:PARTITION-IF-NOT))

Then I was going to go thru the " box set" and replace all defpackage w/
defpackage2

*== (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???)

---

for some reason somewhere in one-liners.lisp it tries to use :
WITH-UNIQUE-NAMES and I always had to choose restart use the

one from CL-PPRE … this time I eval-ed the macro definition while in the  :
it.bese.arnesi package



Appendix:

-- to solve == (1) ==

here is some new code I put into top of file:  split-sequence.lisp ( strangely
this file is the only place that I had to use defpackage2,

but most likely a better place would be in new ?packager? module:

Then we could have a

defpackage2 -> defpackage by default (macro expands to  `(defpackage
,packagename , at args)

and in other lisps

like allegro and lispworks??? We use the macro I wrote to force us to
use symbols
for fnct + package names.



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-package :COMMON-LISP)

;;;;;;;;;;;;;;;;;;;;;;;;

;; allegro likes lower case names for modern images!  *Its really hard to
get

;; the uppercase syms correct ==> so we use a defpackage2 that maps strings

;; to symbols...

;;;;;;;;;;;;;;;;;;;;;;;;

(defun string-2-package-symbol-name (string)

  "convert a string like \"cl\" to sym: :cl"

  (let  ((downcase   (string-downcase  string)))

    ;;(print downcase)

    (read-from-string (format nil ":~A"  downcase))  ;; return a SYM

    ;; (format nil ":~A"  downcase) ;; return a STRING

   ))

;

; (string-2-symbol "cl")

(defun string-2-function-symbol-name (string)

  "convert a string like \"downcase\" to sym: #:downcase"

  (let  ((downcase   (string-downcase  string)))

    ;;(print downcase)

    (read-from-string (format nil "#:~A"  downcase))  ;; return a SYM

    ;; (format nil "#:~A"  downcase) ;; return a STRING

   ))

;

; (string-2-symbol "downcase")

(defmacro defpackage2 (pkg-name &rest spec-list)

  "smartly define a package, hunt for :use :nicknames :export and make any
symbol names specified as a string to be symbols

(defpackage2 :split-sequence

    (:use 'cl')

    (:nicknames 'partition')

    (:export 'split-sequence' 'split-sequence-if' 'split-sequence-if-not'

           'partition' 'partition-if' 'partition-if-not'))

==> converts to:

(DEFPACKAGE :SPLIT-SEQUENCE

  (:USE :CL)

  (:NICKNAMES :PARTITION)

  (:EXPORT #:SPLIT-SEQUENCE #:SPLIT-SEQUENCE-IF #:SPLIT-SEQUENCE-IF-NOT
#:PARTITION #:PARTITION-IF #:PARTITION-IF-NOT))

  "

  (labels  ((convert-all-strings-to-syms  (list  str-to-sym-converter)

              (mapcar  #'(lambda (STR)  (if (stringp STR) (funcall
str-to-sym-converter STR)

                                            STR))  list)))

    (dolist (L  spec-list)

      (case (first L)

        ( (:use :nicknames)

          (format t "fixing ~A~%"  (first L))

          (setf (cdr L)

                ;(convert-all-strings-to-syms  (cdr L)
#'split-sequence:string-2-package-symbol-name )

                (convert-all-strings-to-syms  (cdr L)
#'string-2-package-symbol-name )

                ;;(cdr L)

              ))

        ( (:export)

          (format t "fixing ~A~%"  (first L))

          (setf (cdr L)

                ;(convert-all-strings-to-syms  (cdr L)
#'split-sequence:string-2-function-symbol-name )

                (convert-all-strings-to-syms  (cdr L)
#'string-2-function-symbol-name )

                ;;(cdr L) )

               ))))

    ;; `(quote (defpackage3 ,pkg-name  ,spec-list))  ;;; use this if you
just want it returned quoted to call defpackage3 a fictuous fnct (w/o being
run)

    `(defpackage ,pkg-name  , at spec-list)))

;

;== to test it:

;

; (macroexpand-1 (defpackage2 :split-sequence

;   (:use "cl")

;   (:nicknames "partition")

;   (:export "split-sequence" "split-sequence-if" "split-sequence-if-not"

;          "partition" "partition-if"  "partition-if-not")))

;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

then I do:

;; allegro likes lower case names for modern images!  *Its really hard to
get upper case vs lower case right w/ strings evidently *  defpackage2 will
always work.

#+allegro

(defpackage2 :split-sequence

  (:use "cl")

  (:nicknames "partition")

  (:export "split-sequence" "split-sequence-if" "split-sequence-if-not"

           "partition" "partition-if" "partition-if-not"))

#+allegro
(in-package :split-sequence)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060615/f9af128f/attachment.html>


More information about the bese-devel mailing list