#143 conflicting missing/ignored variable warnings with macro

lisp error
closed-invalid
Sam Steingold
clisp (525)
5
2003-01-31
2003-01-31
Jörg Höhle
No

Please consider this code:
(defmacro with-foreign-string3 ((foreign-variable
element-count byte-count string
&rest keywords
&key (encoding 'custom:*foreign-encoding*)
(null-terminated-p 'T)
(start 0) (end nil))
&body body)
;(declare (ignore encoding null-terminated-p start
end)) ; get via keywords
(list* (list foreign-variable element-count
byte-count string)
keywords body))
(compile 'with-foreign-string3)

Without DECLARE IGNORE, I obtain:
WARNING in function WITH-FOREIGN-STRING3 :
variable ENCODING is not used.
Misspelled or missing IGNORE declaration?
WARNING in function WITH-FOREIGN-STRING3 :
variable NULL-TERMINATED-P is not used.
Misspelled or missing IGNORE declaration?
WARNING in function WITH-FOREIGN-STRING3 :
variable START is not used.
Misspelled or missing IGNORE declaration?
WARNING in function WITH-FOREIGN-STRING3 :
variable END is not used.
Misspelled or missing IGNORE declaration?
WITH-FOREIGN-STRING3

With DECLARE IGNORE, I get
WARNING in function WITH-FOREIGN-STRING3 :
variable ENCODING is used despite of IGNORE
declaration.
WARNING in function WITH-FOREIGN-STRING3 :
variable NULL-TERMINATED-P is used despite of IGNORE
declaration.
WARNING in function WITH-FOREIGN-STRING3 :
variable START is used despite of IGNORE declaration.
WARNING in function WITH-FOREIGN-STRING3 :
variable END is used despite of IGNORE declaration.
WITH-FOREIGN-STRING3

It appears that the warning has to do with the default
initforms being present.

BTW, maybe CLISP should report "warning in MACRO X..."
or "warning in function/macro X..."

BTW2, the link "how to submit bug reports",
http://sourceforge.net/tracker/chttp://clisp.cons.org/l
isp.html#bugs
at the top of this page, is broken.

Regards,
Jörg Höhle.
tested with CLISP-2.28 built with MS-VC6

Discussion

  • Sam Steingold
    Sam Steingold
    2003-01-31

    Logged In: YES
    user_id=5735

    your code is broken: the default values (initforms) you
    supply are always ignored. try macroexpanding your macro.

     
  • Jörg Höhle
    Jörg Höhle
    2003-01-31

    Logged In: YES
    user_id=377168

    I know they are ignored. They are there for documentation
    purposes to the user (DESCRIBE etc.).

    But if they are to be ignored, then DECLARE IGNORE should
    not result in "variable ENCODING is used despite of IGNORE
    declaration". CLISP is contradicting itself here.

    CLISP does not output spurious warnings for functions:
    (defun test (&rest keywords &key (encoding
    custom:*foreign-encoding*))
    (declare (ignore encoding))
    keywords)
    (compile 'test) -> no warning

    I cannot get rid of the spurious warning for macros, that's
    why I submitted a bug-report.

     
  • Sam Steingold
    Sam Steingold
    2003-01-31

    Logged In: YES
    user_id=5735

    use "ignorable" declaration.

     
  • Jörg Höhle
    Jörg Höhle
    2003-01-31

    Logged In: YES
    user_id=377168

    Thanks, ignorable is good enough.

    Hm, I forgot to document the default encoding for
    with-foreign-string. ->

    This forms converts a Lisp string according to encoding,
    allocating
    space on the C execution stack. Encoding can be any
    encoding,
    e.g. charset:utf-16 or charset:utf-8, circumventing the
    usual 1:1
    limit imposed on custom:*foreign-encoding*, which is the
    default.

     
  • Jörg Höhle
    Jörg Höhle
    2003-01-31

    • status: open --> closed
     
  • Sam Steingold
    Sam Steingold
    2003-01-31

    • status: closed --> closed-invalid