This is the mail archive of the kawa@sourceware.org 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]

Re: proposed support for lazy values



On Jun 6, 2011, at 12:24 PM, Per Bothner wrote:


On 06/06/2011 08:45 AM, Charles Turner wrote:
On 06/06/2011 15:28, Jamison Hope wrote:

I would argue that the print at line 4 should say something like "#<promise - force threw a java.lang.Exception>" instead. How about the attached update to your patch?
<Warning: off-topic>

Certainly a better error message, but I have a concern. Back when I was
fixing up some error messages, I noticed an aweful lot of ad-hoc errors
being directly written to an output buffer, just like this patch. It
seems to me that all errors should be encapsulated by a common error
class. This would mean the messages would be consistent and less
confusing. It would also be easier to extend such error classes to
things like the Swing REPL or WebSocket REPL's, etc to do more
interesting formatting. It's going to be a chore going through and
abstracting such messages, but I think it would be worthwhile.

We may gnu.text.SourceError, as well as the interface javafx.tools.Diagnostic.
Though perhaps some new class may be needed, but let's call it Diagnostic.

Did you mean javax.tools.Diagnostic?


I could see that say the Swing REPL can special-case "printing" a Diagnostic,
like it already does for Viewable and Paintable objects. A Diagnostic would
embed an object is the output. The object might by default look like the
result of toString, but it could also (for example) allow clicking for more information.
The source information might be an active hyperlink. And so on.


Still, the devil is in the details ...

That does seem like it would be handy. What would the new Diagnostic class provide,
though, beyond what's already in java.lang.Throwable and its StackTraceElement[]?
(And where would it get its extra information?)


We could probably get part of the way there just by replacing
out.write(throwable.getClass().getName());
with
out.writeObject(throwable);
and updating ReplPaneOutPort's print(Object) to do something fancier when given an instance
of Throwable.


-Jamie

--
Jamison Hope
The PTR Group
www.theptrgroup.com




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