This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

new Kawa options/warninsg framework


Thanks to funding from Marced systems, the CVS version of
Kawa now has a new framework for controlling compiler
warnings and other options.  You can specify an option on
the kawa command line, or you can use the new Scheme syntax
forms with-compile-options and module-compile-options.  The
new flag --warn-undefined-variable is useful for catching typos.
The flag --no-warn-invoke-unknown-method can turn off warnings
when using 'invoke' with an unknown receiver class.

Chris Dean reports (quoted with permission) that the former flag:

  catches bugs all the time now.  In the bad old days, we had to wait
  for a regression test to run before we would find some of the
  misspelled variables.  Now, they are all caught during compile time
  as part of the normal development.

Here is the new documentation in the Kawa manual:

Compilation options
===================

Various named option control how Kawa compiles certain forms.

`--module-static'
     If no `module-static' is specified, generate a static module (as
     if `(module-static #t)' were specified). *Note Module classes::.

`--warn-invoke-unknown-method'
     Emit a warning if the `invoke' function calls a named method for
     which there is no matching method in the compile-time type of the
     receiver.  This (currently) defaults to on; to turn it off use the
     `--no-warn-invoke-unknown-method' flag.

`--warn-undefined-variable'
     Emit a warning if the code references a variable which is neither
     in lexical scope nor in the compile-time dynamic (global)
     environment.  This is useful for catching typos.

   An option can be followed by a value, as in
`--warn-invoke-unknown-method=no'.  For boolean options, the values
`yes', `true', `on', or `1' enable the option, while `no', `false',
`off', or `0' disable it.  You can also negate an option by prefixing
it with `no-': The option `--no-warn-invoke-unknown-method' is the same
as `--warn-invoke-unknown-method=no'.

   You can set the same options (except, for now, `module-static')
within your Scheme source file.  (In that case they override the
options on the command line.)

 - Syntax: module-compile-options [key: value] ...
     This sets the value of the `key' option to `value' for the current
     module (source file).  It takes effect as soon it is seen during
     the first macro-expansion pass, and is active thereafter (unless
     overridden by `with-compile-options').

     The KEY is one of the above option names.  (The following colon
     make it a Kawa keyword.)  The VALUE must be a literal value:
     either a boolean (`#t' or `#f'), a number, or a string, depending
     on the KEY.  (All the options so far are boolean options.)

          (module-compile-options warn-undefined-variable: #t)
          ;; This causes a warning message that y is unknown.
          (define (func x) (list x y))

 - Syntax: with-compile-options [key: value] ... body
     Similar to `module-compile-options', but the option is only active
     within BODY.
          (define (func x)
            (with-compile-options warn-invoke-unknown-method: #f
              (invoke x 'size)))

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]