chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] define-foreign-type and unusad variable warnings


From: Thomas Bushnell BSG
Subject: [Chicken-hackers] define-foreign-type and unusad variable warnings
Date: Fri, 20 Nov 2009 13:56:34 -0800

The use of define-foreign-type creates secret global variables with
gensymed names which are used to wrap around the argument conversion
functions.  Two such names are created for each define-foreign-type form
(indeed, if the optional RETCONVERT is not provided, a global is still
created to hold it which ends up doing (values) instead of calling
something).  See the code in compiler.scm which canonicalizes a
define-foreign-type form.

The problem is that if you define a foreign type but don't happen to use
one of the conversions in the actual code, you get a spurious "global
variable `g862' is never used" warning.  Of course you can make this go
away with (declare (disable-warning var)), but that's overkill.  I do
want warnings, just not spurious ones.  Normally it is useful to do
(declare (unused ...)) but that doesn't work here, because the variables
created have secret gensymed names.

I think that this could be avoided if, for example, foreign types were
treated as first class objects.  All the existing syntax could be
preserved.  Define-foreign type would no longer be a special case; it
could just be
(define-syntax define-foreign-type
  (syntax-rules ()
    ((_ name type argconvert) (cons argconvert values))
    ((_ name type argconvert retconvert) (cons argconvert retconvert))))

Or something like that; I'm no expert on this area of the system.

Perhaps, indeed, it might be fully sufficient to use a "mark" in the
compiler, to mark the magical gensymed variables as used (the way they
are currently marked with the 'always-bound tag).

Thomas







reply via email to

[Prev in Thread] Current Thread [Next in Thread]