Re: File and line number in the source file

Cyprien Nicolas <[email protected]>
Newsgroups gmane.lisp.scheme.bigloo
Message-ID <[email protected]>
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,

-- 
Cyprien Nicolas, PhD Student, INDES Team
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iEYEARECAAYFAlPI7W0ACgkQQHQZc4Ru+vF8uQCfeYksHAetdfydxtBre5ge4dnn
jxUAnj97eUHIBulA8Qw/Poz9vL4bdUSJ
=Lw1K
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.