[eclipse-clp-users] line numbers in calling goals

From: Basile Starynkevitch <basile_at_...352...>
Date: Wed, 13 Feb 2013 08:54:05 +0100
Hello All,

In C or C++ I would routinely have

   #define dbgprintf(Fmt,...) do{if(debugging) printf("%s:%d:" Fmt "\n", __FILE__,__LINE__, ##__VA_ARGS__);}while(0)

and then I would use at many places things like (in file foo.c line 123)
    dbgprintf("here x=%d", x);
with an output like
    foo.c:123: Here x=10

Is it possible to get the line number of the invoking super-goal in Eclipse Prolog?

So far in https://github.com/bstarynk/BOPL-APS

I'm coding  
dbgprintf(Name,Fmt,Args) :- 
        debugWanted(Name), atom(Name) 
	-> printf(output, "*| %a ",[Name]), printf(output, Fmt, Args), nl, !
        ; true, !

then later using
	dbgprintf(parseVarsList," TokensAfterKwVars=%w", [TokensAfterKwVars]),

assuming that I would assert debugWanted(parseVarsList) somewhere

but this don't give me the line number.

Perhaps the attribute feature might help, because I'm guessing 
that Compiler/source_processor.ecl is keeping the source location...

But I am not familiar enough with Eclipse CLP to understand if it is feasible or not.

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Received on Wed Feb 13 2013 - 07:54:20 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST