English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-11-06 (22:21)
From: Hendrik Tews <tews@t...>
Subject: Re: Assert

Xavier Leroy writes:
   From: Xavier Leroy <Xavier.Leroy@inria.fr>
   Date: Fri, 3 Nov 2000 11:37:52 +0100
   Subject: Re: Assert
   > List,
   >     I still cannot figure out why the assert instruction
   > does not return the line number at which the exception occures.
   Basically, it's because the compiler uses character numbers
   internally; line numbers are computed only when printing an error message.
>From what I can see from the sources, for every error and warning
message the whole source file is parsed again with a special
lexer to determine the line number (parsing/linenum.mll). Could
anybody comment on this approach to printing error messages? (It
seems very very very strange to me.)

Besides that I have another suggestion for the 
this discussion thread about escaping assertions:

Would it be possible to reserve a keyword (or a standard library
symbol) "current_line_number" that, by magic, expands to its
location (a tuple or triple of integers) in the source file? This
way the magic of assert would be available for us users, one
could write

try ....
  | a -> prerr_endline( "Exception " ^ (Printexc.to_string a) ^ 
                        " escaping at " ^ 
                        ( ... current_line_number))