Discussion:
Line numbers for scm_c_primitive_load() errors
Robert Gill
2018-03-31 05:30:18 UTC
Permalink
I'm trying to read a file with scm_c_primitive_load() that uses some
custom functions defined with scm_c_define_gsubr(). If I pass an invalid
data type to one of these functions, I get an expected exception, but
the line number of the file where they occur is not included in the
stack trace. I tried following the directions in the manual under
'6.25.3.2 Capturing the full error stack', and wrapping the call in
scm_c_catch(), while manually capturing the stack, but it still doesn't
seem to include the line number.

I'm using guile 2.0.14.
Mike Gran
2018-03-31 16:09:32 UTC
Permalink
Post by Robert Gill
I'm trying to read a file with scm_c_primitive_load() that uses some
custom functions defined with scm_c_define_gsubr(). If I pass an invalid
data type to one of these functions, I get an expected exception, but
the line number of the file where they occur is not included in the
stack trace. I tried following the directions in the manual under
'6.25.3.2 Capturing the full error stack', and wrapping the call in
scm_c_catch(), while manually capturing the stack, but it still doesn't
seem to include the line number.
I'm using guile 2.0.14.
Yeah. Guile only attaches line numbers to some of the locations in a
file, like 'define'; many of the inner expressions have no location
attached.

One strategy is to evaluate a file one expression at a time, and then
hold onto the last expression that had locations attached to it. When an
error occurs, the last expression that had locations attached is
probably above or next to the expression causing the error.

Consider the attached program

Hope this helps

-Mike Gran
Robert Gill
2018-03-31 23:40:05 UTC
Permalink
Post by Mike Gran
Yeah. Guile only attaches line numbers to some of the locations in a
file, like 'define'; many of the inner expressions have no location
attached.
One strategy is to evaluate a file one expression at a time, and then
hold onto the last expression that had locations attached to it. When an
error occurs, the last expression that had locations attached is
probably above or next to the expression causing the error.
Consider the attached program
Hope this helps
-Mike Gran
Thank you! I think that should work for what I'm doing.

Loading...