Re: Getting the current line number
John Reppy <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
No, but you might be able to run your sml code through the C
preprocessor
to get that information. I don't know it any SML implementation
provides
this feature, but it might be a useful thing to standardize on (also
__FILE__).
After thinking about it a bit more, I realized that the following hack
would work. First, define the following helper function
fun file_line ex = let
val [s] = SMLofNJ.exnHistory ex
val (f, r) = Substring.splitl (fn #":" => false | _ => true)
(Substring.full s)
val ln = Substring.takel (fn #"." => false | _ => true)
(Substring.triml 1 r)
in
{file = Substring.string f, line = Substring.string ln}
end;
then you can get the file and line info at a given source code location
by embedding the following code:
file_line ((raise Fail "") handle ex => ex);
- John
On Oct 17, 2005, at 11:36 AM, Geoffrey Alan Washburn wrote:
> Is there an equivalent to C's __LINE__ for SML/NJ?
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl