Re: File and line number in the source file
Guilhem de Wailly <[email protected]>
| Newsgroups | gmane.lisp.scheme.bigloo |
|---|---|
| Message-ID | <[email protected]> |
Hi Cyprien, Thank you so much for the information! Have a nice day Guilhem Le 18/07/2014 11:48, Cyprien Nicolas a écrit : > Hello Guilhem, > > Il y a environ 33 minutes, [email protected] écrivit : >> Hello, >> >> For some reasons, I would like to print the current source file name and the >> current line number (aka an assert macro)... >> >> Is there a way to get these information in Bigloo? > You can have this piece of information for any list, either the list > is a scheme expression you access at macro-expansion time, or any list > defined using que quote operator. I guess the information is added by > the read function. > > The location is available using the CER primitive (which appears to be > undocumented). The CER value either contains a list of three elements > in the form '(at filename char-position), or #f if no location > information is available. > > For instance, within the REPL : > > > 1:=> (define bla '(some value)) > bla > 1:=> (cer bla) > (at stdin 13) > 1:=> (typeof bla) > epair > 1:=> > > > The primitive ERROR/LOCATION and WARNING/LOCATION know how to > translate the character position into line & column numbers. > > The CER primitive can only be called on `epair' structures, ortherwise > it will raise a type error. > > Regards, >