> different levels of reporting compilation errors
> The level of detail was user selectable...
This might be doable, without changing the interpreter.
We could create a verb which, given a J sentence, would interpret it and spit
out more detailed error messages. We could probably
leverage the trace, debug, and primitive scripts to this end.
A brief sketch: the user loads our special 'verbose_debug' script. He
executes his program. It suspends.
We take the sentence which suspended and trace it, spitting out any rhematic or
syntactic errors (open quote, spelling error,
syntax error, ill-formed name, ill-formed number).
If it passes muster syntatically, we'd have to move on to semantic analysis, by
substituting the primitives in the sentence by
named replacements. The named replacements are just covers to the normal
primitive, with a lot of verbose precondition checking.
There are some hurdles to overcome here. For one thing, debug only suspends in
named explicit definitions. So for anonymous
explicit definitions, we'd have to recurse (which opens a can of worms wrt side
effects). Well, I guess we'd have to recurse
anyway, for cases like ". 'a:+4' or 'ill-formed name'=:0 or even gerund-y
siutations like ^:('blah.';'spelling:') .
Another problem is that we don't know all the existing preconditions. And even
the ones we "know" we probably won't be able to
recall while writing the script. I guess we'd have to evolve the script over
time. And, not only that, but we're going to have
to keep it up to date (e.g. when a 'nonce error' gets fixed).
The more I think about it, the less enthused I am about writing it.
-Dan
PS: BTW, there is some documentation on J's errors:
http://www.jsoftware.com/help/dictionary/errors.htm
It's short but better than nothing, and people new to J might not be aware of
it (these are also the people most likely to be
frustrated by terse error messages). Another useful tip can be found at:
http://www.jsoftware.com/help/dictionary/dictj.htm
which notes that the error text indicates where parsing stopped (ie where the
error occurred), by inserting four blanks.
With that said, I'll offer a cavaet: J does not treat errors formally. For
example, see this bug report:
http://www.jsoftware.com/jwiki/System/Interpreter/Bugs06#head-5c38178385cf2d5093223f5f431d3b7edf996f2e
and Roger's response.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm