Why can't CLISP call certain functions with uninitialized names?

I wrote a special parser generator that creates code to convert an old and little-known 7-bit character set to unicode. The parser generator call expands into a bundle defunenclosed in progn, which is then compiled. I want to show only one of the generated defuns - the upper level - for the rest of the system; all others are internal to the parser and are only called from the top-level dynamic region. Therefore, the other defungenerated ones have uninterned names (created using gensym). This strategy works fine with SBCL, but I recently tested it with CLISP and I am getting errors like:

*** - FUNCALL: undefined function #:G16985

It seems that CLISP is not able to handle functions with non-integer names. (Interestingly, the system compiled without problems.) EDIT: It seems that in most cases it can handle functions with non-integer names. See Rord's answer below.

My questions: is this a problem with CLISP, or is it a Common Lisp constraint that undergoes certain implementations (e.g. SBCL)?

EDIT:

For example, the macro extension of a generated top-level function (called parse) has the following expression:

(PRINC (#:G75735 #:G75731 #:G75733 #:G75734) #:G75732)

Evaluating this expression (by calling parse) produces an error similar to the one above, although the function is definitely defined within the same macro extension:

(DEFUN #:G75735 (#:G75742 #:G75743 #:G75744) (DECLARE (OPTIMIZE (DEBUG 2)))
 (DECLARE (LEXER #:G75742) (CONS #:G75743 #:G75744))
 (MULTIPLE-VALUE-BIND (#:G75745 #:G75746) (POP-TOKEN #:G75742)
 ...

#: G75735 - , , - . , SBCL, CLISP.

EDIT:

SO Joshua Taylor , CLISP.

+4
5

, , , , , , , .

, lisp symbol-function. , .

, , .. labels , ?

EDIT. CLISP.

, , gensym, .

[1]> (defmacro test ()
(let ((name (gensym)))
`(progn
(defun ,name () (format t "Hello!"))
(,name))))
TEST
[2]> (test)
Hello!
NIL

, , , defun? , defun s, - , , , SBCL CLISP - , .

2. , CLISP , , . , load lisp CLISP compile-file , load FASL.

, , , CLISP. - " , (FDEFINITION '#: G3219)". CLISP .

, -. HyperSpec :

n. ; , : ( , ), ( ). undefined, , . . .

, , , " ".

EDIT 3: ( , , CLISP . -, , . - , , - " " )

, , CLISP, , :

(defmacro test ()
  (let* ((pkg (make-package (gensym)))
         (name (intern (symbol-name (gensym)) pkg)))
    `(progn
       (defun ,name () (format t "Hello!"))
       (,name))))

(test)

EDIT 4: , (10 ) CLISP # 180.

, , , progn locally , let () .

+5

, , , . :

CL-USER> (defun #:foo (x)
           (list x))
#:FOO
CL-USER> (defparameter *name-of-function* *)
*NAME-OF-FUNCTION*
CL-USER> *name-of-function*
#:FOO
CL-USER> (funcall *name-of-function* 3)
(3)

sharpsign colon , :

#: , -. , , . .

, -

CL-USER> (list '#:foo '#:foo)
;=> (#:FOO #:FOO) 

, , :

CL-USER> (eq '#:foo '#:foo)
NIL

, ​​, #:, , , :

CL-USER> (#:foo 3)
; undefined function #:foo error

, , - , , . , , . , ​​ , :

(defun #1=#:fact (n &optional (acc 1))
  (if (zerop n) acc
      (#1# (1- n) (* acc n))))

#1=#:fact #1#, . , , :

CL-USER> (pprint '(defun #1=#:fact (n &optional (acc 1))
                    (if (zerop n) acc
                        (#1# (1- n) (* acc n)))))

(DEFUN #:FACT (N &OPTIONAL (ACC 1))
  (IF (ZEROP N)
      ACC
      (#:FACT (1- N) (* ACC N))))

, "", #:FACT, ( undefined):

CL-USER> (DEFUN #:FACT (N &OPTIONAL (ACC 1))
           (IF (ZEROP N)
               ACC
               (#:FACT (1- N) (* ACC N))))

; in: DEFUN #:FACT
;     (#:FACT (1- N) (* ACC N))
; 
; caught STYLE-WARNING:
;   undefined function: #:FACT
; 
; compilation unit finished
;   Undefined function:
;     #:FACT
;   caught 1 STYLE-WARNING condition
+2

, . CLISP.

: GENSYM-ed.

(defmacro test ()  
  (let ((name (gensym)))  
    `(progn  
       (defun ,name (x) (* x x))  
       ',name)))

(setf x (test)) (funcall x 2).

0

, , , . , " ", uninterned ( , "uninterned" , ).

- , . , .

0

, CLISP 180 ANSI CL. , , , ANSI Common Lisp , progn .

Lisp - , , , , , ( "" ). ANSI Common Lisp , , , . (CLHS 3.2.4 ).

-, (3.2.4.2.2 ), , - . , , , , , () : .

, , ? , , , ? , .

: , , : , . , . , '#1=(a b . #1#), , , , , ( ). conses : , car cdr . ( , ).

- , , ; , (3.2.4.3 ).

, ANSI CL, gensyms , , . , , :

(defmacro foo (arg)
   (let ((g (gensym))
         (literal '(blah ,g ,g ,arg)))
      ...))

(defun bar ()
  (foo 42))

bar gensym, conses , .

, , " ".

, " CLISP..." , , CLISP , , , . ( *print-circle*, .) , CLISP , , , , , .

0

All Articles