Dnia 25-02-2007, nie o godzinie 17:18 -0500, William D Clinger
napisa?(a):
> That's a great idea, but it isn't implementable in a
> useful way. You can't check the syntax until after
> macro expansion, and you can't decide whether macro
> expansion will terminate; hence you can't accept all
> statically valid programs while rejecting all that
> are not (unless you adopt some trivial definition of
> statically valid, such as that all lexically correct
> datums are statically valid programs).
It is reasonable to have a program accepted by one implementation and
rejected by another if it uses a macro which expands to a valid or
invalid code depending on the order of evaluation of function arguments.
It's not reasonable to have a program rejected by an implementation
which has determined that after function inlining it contains a division
by literal 0. Because:
a) this might be dead code, guarded by macro-generated conditionals
which are always false,
b) even if it's a genuine bug, the one who discovers it might be
a different person than the one who can fix it, since not all
implementations are required to detect it.
My compiler of my language makes extra effort to generate code which
always fails when it detects division by literal 0, and emits a warning,
even though rejecting the code would be a bit simpler, because division
by 0 is not considered a static error.
My compiler has two levels of warnings:
1. Regular warnings, signaled when the code is almost surely a bug,
even though it doesn't break any rule which I consider a static
constraint. For example calling a known function with a bad number
of arguments. These warnings cause the compiler to exit with a non-0
exit code, which causes a standard Makefile to abort, but the
compiled code is still being generated, since the program is formally
valid.
2. Notes, signaled when the code is just suspicious, but there is a
chance that it's correct. For example defining a name which is never
used. They are only shown during compilation.
(I might add compiler options which change the rules for the exit code:
one to exit with 0 for all valid code, and another to exit with non-0
if there is anything suspicious.)
--
__("< Marcin Kowalczyk
\__/ qrczak_at_knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
Received on Mon Feb 26 2007 - 09:17:18 UTC