This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> Well, the application in question does not have a repl loop, but does > need to call bits of Scheme code in response to X events. In > particular, it may need to either call a procedure or evaluate a > string directly from the C code. When this happens I need errors to be > reported in the nicer format, and control to return to the point where > the evaluation was being attempted. I think other applications will > need to do similar things - for example, a spreadsheet that uses Guile > for it's macro langauge will likely want nice error reporting but > probably does invoke a repl when evaluating a macro. I had an idea of setting up an error stack. I've seen it done to some extent elsewhere but never done well. The basic idea is that if the error stack is empty then no errors have occured. The first error that occurs is pushed to the stack and code drops back to either a handler or the calling routine. The error stack is checked and if there's something on it then you can either keep dropping back, pop the error off if you know how to fix it or push on some additional comment. The error stack entries can have some sensible structured format that is suitable for both dumping to stderr or for automatic analysis or for reformatting into pop-up warnings for GUI apps. Well, I haven't given this issue a lot of thought because I haven't got enough code to need error reporting yet but I can see it slowly becomming a bigger problem in the future. One thing piss-poor about C is the inconsistent and inconvenient way that it handles errors. C++ tried to go the way of exceptions and it's not very satisfactory when switching them on adds 20% of size to your executable and (in my experience) they are more difficult to use than just putting if statements in after calls. I like Java exceptions because they are well integrated into the language and you get detailed stack dumps. Also, all of the errors are documented objects that you can add data to as you see fit -- making it easy to catch and reformat the errors as you need. An error system similar to Java would be great but I don't think it's achievable in guile, mostly because of the way C code is mixed with interpreted code, it would be nice to have a mechanism that's consistent in C and scheme (or close to). - Tel