> It seems to me you need to distinguish runtime errors from compilation
> errors. For runtime errors, the file and line numbers are already in
> the stack trace, as Clojure emits that information in the bytecode.
> For example, in the above trace:
>
> >         at user.eval__2291.invoke(broken-arity.clj:6)
>
> I'm not going to make any changes for people unwilling to look a few
> lines down in a stack trace.

I don't think that unwillingness is the only criteria here. One reason
is for consistency. We're already heading down the track of making
compiler error messages easier to read. It doesn't seem very friendly
to make the compiler error messages easier and then intentionally
leave the runtime errors obfuscated. Another reason is ease of
understanding. I can read the stack trace just fine, but I will
happily write the patch just because it makes my edit-compile-test
cycle easier and faster. It's much easier to read the problem at the
top than to filter through the stack trace.

>
> A new exception class hierarchy that duplicates these values seems
> redundant. The world does not need more exception types, or a
> reinvention of stack traces, IMO.

I've seen cases where the default Java exception.printStackTrace()
doesn't include the entire stack and the part that I care about is
hidden in that "and 60 more lines" message. I think there it's
entirely appropriate to write our own printStackTrace() that does
display everything. I'll post to the group the next time I see one of
those.

My goal in creating a new exception type was to avoid copy&paste code.
At the point where you want to throw a new exception, I see a few
possible choices here.

1) throw new java.lang.IllegalArgumentException("Too many arguments to
def");
2) throw new
java.lang.IllegalArgumentException(Compiler.SOURCE_PATH.get() + " line
" + Compiler.LINE_AFTER.get() + "Too many arguments to def");
3) throw new
java.lang.IllegalArgumentException(Compiler.exceptionPrefix() + "Too
many arguments to def");
4) throw new Clojure.CompileError("too many arguments to def");

where Compiler.exceptionPrefix() is

String exceptionPrefix()
{
   return Compiler.SOURCE_PATH.get() + " line " +
Compiler.LINE_AFTER.get();
}

1 is the current code. 2,3,4 have the same behavior, with increasing
levels of encapsulation. I assume you are in favor of 3) then?

Allen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to