A few questions
Era Scarecrow
rtcvb32 at yahoo.com
Fri Jul 27 12:44:15 PDT 2012
On Friday, 27 July 2012 at 19:01:39 UTC, Namespace wrote:
> I also get null references (and every time I hate D a bit
> more), but mostly my classmates and other friends whom I've
> shown D. And most of them are already back to C++ or C#. And I
> can understand them.
> If you want that D is sometimes taken seriously (and it reached
> only if you win more people for D), then perhaps you should do
> something for more usability.
> Such small handy shorthands are easy to implement and even more
> understandable as a stacktrace.
I've noticed when debugging the 'segfault' is rather vague, but
it depends on if you have something to catch it. In some of my
code I end up surrounding the main function in a try/catch
wrapper that prints the appropriate data; Like using VisualD.
void main() {
try {
someFunc(null);
} catch (Throwable x) {
writeln(x);
}
}
void someInnerFunc(Object o)
in {
assert(o, "Yo! my object's NULL!");
}
body {
//something
}
void someFunc(Object o) {
someInnerFunc(o); //for stacktrace
}
core.exception.AssertError at test.d(111): Yo! my object's NULL!
----------------
c:\Users\Era\My Documents\progs\d\test.d(119): void
test.someFunc(Object)
c:\Users\Era\My Documents\progs\d\test.d(103): _Dmain
change inner function to:
void someInnerFunc(Object o) {
o.toHash;
//something
}
object.Error: Access Violation
----------------
c:\Users\Era\My Documents\progs\d\test.d(116): void
test.someFunc(Object)
c:\Users\Era\My Documents\progs\d\test.d(103): _Dmain
More information about the Digitalmars-d-learn
mailing list