less verbose compiler messages

Suggestions for new Logtalk features

Moderator: Paulo Moura

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

less verbose compiler messages

Post by joerg » Wed Jan 28, 2009 12:56 pm

Hello,

here is yet another wish.

I usually compile Logtalk programs with very many objects. As Logtalk prints

% >>> compiling source file FILE...
[...]
(N warnings)

for every source file FILE

and

% compiling object OBJECT... compiled

for every object OBJECT (at [...]), finding the compiler warnings is quite tedious. Sometimes one has to browse through many pages of Logtalk messages. It would be very practical if the compiler flag 'report' did not only have the options 'on' and 'off', but, e.g. an option 'short', which might mean that only warnings are printed.

Jörg

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Wed Jan 28, 2009 2:06 pm

Thanks for the suggestion. I played with implementing a "warning" value for the "report" compiler flag some months ago. The issue with only printing warnings is that you also need to print the context of the warning. Usually, this includes the entity that is being compiled, the source file defining the entity, and the source file line number. This requires a number of changes for the compiler that have been so far postponed due to tasks with higher priority in my "to do" list. I will look again into it for the next stable release.
Paulo Moura
Logtalk developer

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Sun Feb 08, 2009 3:14 am

I have implemented a "warnings" value for the "report" compiler option, providing a less verbose compilation reporting where only warnings are printed:

http://trac.logtalk.org/changeset/4697

Give it a spin and please report any formatting problems you might find.
Paulo Moura
Logtalk developer

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

Re: less verbose compiler messages

Post by joerg » Wed Feb 25, 2009 4:29 pm

Hello Paulo,

sorry for answering so late. I wasn't aware of your reply.

I have downloaded the latest development version of Logtalk, but I don't seem to be able to use it.

I get these error messages (and more):

Code: Select all

[...]

%  logtalk/lgtsvn/integration/logtalk_comp_swi.pl compiled 0.23 sec, 551,048 bytes
%  lgtsvn/libpaths/libpaths.pl compiled 0.00 sec, 17,640 bytes
%  logtalk/lgtsvn/configs/swihook.pl compiled 0.00 sec, 2,308 bytes
ERROR: test.pl:9:
	Domain error: `valid_flag_value' expected, found `warning'
Warning: test.pl:9:
	Goal (directive) failed: user:set_logtalk_flag(report, warning)

[...]

  Multi-threading programming support (threads):              on

ERROR: logtalk/lgtsvn/integration/logtalk_comp_swi.pl:31:
	mutex_create/1: No permission to mutex create `$lgt_threaded_tag'
Warning: logtalk/lgtsvn/integration/logtalk_comp_swi.pl:31:
	Goal (directive) failed: user: (initialization$lgt_startup_message, $lgt_assert_default_hooks, $lgt_start_runtime_threading, $lgt_dbg_reset_invocation_number)

[...]

Jörg

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Wed Feb 25, 2009 5:01 pm

The flag value is misspelt, you want "warnings", not "warning". I plan to release the next Logtalk stable version (2.35.1), which will include this new feature, by March 1. You can subscribe to the forums RSS feed to keep track of new posts.
Paulo Moura
Logtalk developer

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

Re: less verbose compiler messages

Post by joerg » Thu Feb 26, 2009 9:09 am

Ah, o.k. Thank you for the hint.

Here are two other suggestions or questions: (Questions in case I got something wrong.)

According to the manual, the startup message can be suppressed by editing the config file:
To suppress printing of the Logtalk startup banner and default flags, set the option startup_message in the config file that you are using to none.
I changed line 202 of configs/swi.pl to

Code: Select all

'$lgt_default_flag'(startup_message, flags(none)).
and I got this error message:

Code: Select all

Logtalk 2.35.1
Copyright (c) 1998-2009 Paulo Moura

Warning: /home/schuster/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl:31:
	Goal (directive) failed: user: (initialization$lgt_startup_message, $lgt_assert_default_hooks, $lgt_start_runtime_threading, $lgt_dbg_reset_invocation_number)
%   /
I also tried to set startup_message to none using

Code: Select all

:- set_logtalk_flag(startup_message, none).
But this led to the following error message:
ERROR: /home/schuster/bin/lib/load_logtalk.pl:9:
No permission to modify read_only_flag `startup_message'
Warning: /home/schuster/bin/lib/load_logtalk.pl:9:
Goal (directive) failed: user:set_logtalk_flag(startup_message, none)
I think it would be practical for the user if startup_message could be set just like other Logtalk flags.

Another problem I found concerns the flag smart_compilation. If it is set to on, then Logtalk will show the following behaviour: If you compile, say file my_program.lgt and if the compiler reports an error without stopping the compilation procedure, then Logtalk will not compile my_program.lgt again after you have edited and saved my_program.lgt. Instead, it will use the corrupt file my_program.pl and report very strange errors. The problem goes away, if you remove my_program.pl and compile my_program.lgt again. Or at least this is what happens on my laptop.

Jörg

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Thu Feb 26, 2009 9:45 am

joerg wrote: I changed line 202 of configs/swi.pl to

Code: Select all

'$lgt_default_flag'(startup_message, flags(none)).
This should be:

Code: Select all

'$lgt_default_flag'(startup_message, none).
joerg wrote: I think it would be practical for the user if startup_message could be set just like other Logtalk flags.
What would be the point of allowing this flag to be changed after startup?
joerg wrote: Another problem I found concerns the flag smart_compilation. If it is set to on, then Logtalk will show the following behaviour: If you compile, say file my_program.lgt and if the compiler reports an error without stopping the compilation procedure, then Logtalk will not compile my_program.lgt again after you have edited and saved my_program.lgt. Instead, it will use the corrupt file my_program.pl and report very strange errors. The problem goes away, if you remove my_program.pl and compile my_program.lgt again. Or at least this is what happens on my laptop.
Which back-end Prolog compiler are you using? The Logtalk compiler catches any exceptions thrown by the Prolog compiler. The only way to get an error without the compilation being aborted is with a buggy Prolog compiler that prints an error message but does not throw an exception. Usually the problem occurs when loading the intermediate Prolog file generated by Logtalk. This signals a bug in the Prolog implementation of the write_canonical/2 or/and read_term/3 predicates. I.e. the Prolog compiler writes terms that it fails to read back.
Paulo Moura
Logtalk developer

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

Re: less verbose compiler messages

Post by joerg » Thu Feb 26, 2009 11:28 am

Code: Select all

'$lgt_default_flag'(startup_message, none).
Thank you. I thought I just had to replace "verbose" with "none".
What would be the point of allowing this flag to be changed after startup?
O.k. there is probably no point in doing it after startup. I just felt that the user should not have to edit the Logtalk source code, but rather one and only one configuration file. Logtalk might read this file once -- for example when it is called in configuration mode -- and then use its information at every startup. But it is not that important, as long as there is some way to do it ...

I use to load my Logtalk programs by consulting the following Prolog program:

Code: Select all

:- consult('~/bin/logtalk/lgtsvn/configs/swi.pl').
:- consult('~/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl').
:- consult('~/bin/logtalk/lgtsvn/libpaths/libpaths.pl').
:- consult('~/bin/logtalk/lgtsvn/configs/swihook.pl').
:- set_logtalk_flag(xmldocs, off).
:- set_logtalk_flag(portability, warning).
:- set_logtalk_flag(smart_compilation, on).
:- set_logtalk_flag(report, warnings).
When I install a new Logtalk version, I just have to put it somewhere and edit this file.

Which back-end Prolog compiler are you using?
SWI-Prolog (Multi-threaded, 32 bits, Version 5.6.64). Maybe the problem goes away with the next version of SWI-Prolog ...

Jörg

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Thu Feb 26, 2009 12:06 pm

joerg wrote: O.k. there is probably no point in doing it after startup. I just felt that the user should not have to edit the Logtalk source code, but rather one and only one configuration file. Logtalk might read this file once -- for example when it is called in configuration mode -- and then use its information at every startup. But it is not that important, as long as there is some way to do it ...
There is no need to edit the Logtalk source code. There is also only a single configuration file per Prolog compiler (in the "configs" directory), which is used at every startup. This configuration file is intended to be edited by the user in order to set appropriated values for the compiler flags. These values act as default values; they can always be changed at runtime or in application loader files.
joerg wrote: I use to load my Logtalk programs by consulting the following Prolog program:

Code: Select all

:- consult('~/bin/logtalk/lgtsvn/configs/swi.pl').
:- consult('~/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl').
:- consult('~/bin/logtalk/lgtsvn/libpaths/libpaths.pl').
:- consult('~/bin/logtalk/lgtsvn/configs/swihook.pl').
:- set_logtalk_flag(xmldocs, off).
:- set_logtalk_flag(portability, warning).
:- set_logtalk_flag(smart_compilation, on).
:- set_logtalk_flag(report, warnings).
When I install a new Logtalk version, I just have to put it somewhere and edit this file.
You may also want to set the "altdirs" and "tmpdir" compiler flags. They allow you to keep the intermediate Prolog files (that are generated when compiling Logtalk source code) out of the way.
joerg wrote:
Which back-end Prolog compiler are you using?
SWI-Prolog (Multi-threaded, 32 bits, Version 5.6.64). Maybe the problem goes away with the next version of SWI-Prolog ...
I'm not aware of any bug in SWI-Prolog that would cause the problems you described. Can you post the error message that does not abort the compilation process? Thanks.
Paulo Moura
Logtalk developer

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

Re: less verbose compiler messages

Post by joerg » Thu Feb 26, 2009 12:17 pm

I'm not aware of any bug in SWI-Prolog that would cause the problems you described. Can you post the error message that does not abort the compilation process?
Well, here is one example. To reproduce it, just use two commas at the end of a clause.

Code: Select all

?- consult(parse).
%   /home/schuster/bin/logtalk/lgtsvn/configs/swi.pl compiled 0.01 sec, 22,700 bytes
%   /home/schuster/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl compiled 0.35 sec, 550,692 bytes
%   /home/schuster/bin/logtalk/lgtsvn/libpaths/libpaths.pl compiled 0.00 sec, 17,640 bytes
%   /home/schuster/bin/logtalk/lgtsvn/configs/swihook.pl compiled 0.00 sec, 2,308 bytes
%  /home/schuster/bin/lib/load_logtalk.pl compiled 0.36 sec, 595,856 bytes
%  tools.pl compiled 0.01 sec, 26,196 bytes
% (0 warnings)

%         ERROR!    syntax_error(operator_expected)
%                   in file('parser.lgt', 177, 8, 4769)
%                   in file parser.lgt, above line 184
ERROR: Unknown error term: error(syntax_error(operator_expected), file(parser.lgt, 177, 8, 4769))
Warning: Goal (directive) failed: user:logtalk_load(parser)
% parse compiled 0.47 sec, 651,528 bytes
true.

?- 

The program parse.pl has this content:

Code: Select all

:- consult('~/bin/lib/load_logtalk.pl').
:- logtalk_load(tools).
:- logtalk_load(parser).

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Thu Feb 26, 2009 12:34 pm

I cannot reproduce the problem:

Code: Select all

electra:~ pmoura$ cat j.lgt

error..

electra:~ pmoura$ swilgt.sh 

Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.6.63)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
%  /Users/pmoura/lgtsvn/configs/swi.pl compiled 0.01 sec, 183,096 bytes

Logtalk 2.35.0
Copyright (c) 1998-2009 Paulo Moura
...
?- set_logtalk_flag(smart_compilation, on).
true.

?- {j}.
%  <<< loading source file j... 
%  >>> compiling source file j...
%          ERROR!    syntax_error(end_of_file)
%                    in: file('j.lgt', 4, 0, 10)
%                    above line: 4
ERROR: Unknown error term: error(syntax_error(end_of_file), file(j.lgt, 4, 0, 10))
?- edit(file('j.lgt')).
% Waiting for editor ... 
% Running make to reload modified files
% Scanning references for 1 possibly undefined predicates
true.

?- {j}.
%  <<< loading source file j... 
%  >>> compiling source file j...
%  >>> j source file compiled
% j.pl compiled 0.00 sec, 460 bytes
%  <<< j source file loaded
%  (0 warnings)
true.
When the "smart_compilation" compiler flag is turned on, Logtalk compares the time stamps of the Logtalk source file and the intermediate Prolog source file. Correcting the syntax error when saving the source file results in a time stamp newer than the intermediate Prolog file generated in the previous aborted compilation. In this case, Logtalk just recompiles the source file. There should be no need of manually removing the intermediate Prolog file. Could this be a problem with the text editor you're using? Which operating-system are you running in your laptop?
Paulo Moura
Logtalk developer

Parker
Posts: 33
Joined: Wed Feb 27, 2008 2:51 pm

Re: less verbose compiler messages

Post by Parker » Thu Feb 26, 2009 12:46 pm

Paulo Moura wrote:
joerg wrote: O.k. there is probably no point in doing it after startup. I just felt that the user should not have to edit the Logtalk source code, but rather one and only one configuration file. Logtalk might read this file once -- for example when it is called in configuration mode -- and then use its information at every startup. But it is not that important, as long as there is some way to do it ...
There is no need to edit the Logtalk source code. There is also only a single configuration file per Prolog compiler (in the "configs" directory), which is used at every startup. This configuration file is intended to be edited by the user in order to set appropriated values for the compiler flags. These values act as default values; they can always be changed at runtime or in application loader files.
[...]
You may also want to set the "altdirs" and "tmpdir" compiler flags. They allow you to keep the intermediate Prolog files (that are generated when compiling Logtalk source code) out of the way.
I also find it a bit strange to have to edit a config file to change what are essentially project-specific parameters. The natural place to change such settings (in my opinion) would be either in the loader or some other project-specific file. (You may recall we already discussed this Paulo). What if the user has multiple projects each requiring different config settings? Also updating Logtalk shouldn't lose the project-specific information (I know it is backed-up).

Just an idea: perhaps the config file could be split up into:
  • backend-specific parameters and predicates: These are immutable and installation-wide. e.g.'$lgt_predicate_property'/2
  • default settings: These are mutable, (i.e. can be overridden by the loader) and are project-specific. e.g. altdirs
Does that cover all the cases?

Cheers,
Parker

joerg
Posts: 40
Joined: Fri Dec 21, 2007 9:38 am

Re: less verbose compiler messages

Post by joerg » Thu Feb 26, 2009 12:53 pm

I could not reproduce the error with your file j.lgt either. It seems that the file has to contain at least an object definition.

The following code was sufficient to produce the error on my system:

Code: Select all

:- object(test_object).

    :- public(test/0).

    test :-
        write(hallo), nl,. %! The error is here

:- end_object.

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Thu Feb 26, 2009 1:20 pm

Parker wrote: I also find it a bit strange to have to edit a config file to change what are essentially project-specific parameters.
You don't need to edit a config file to change project-specific parameters, only to change default parameter values.
Parker wrote: The natural place to change such settings (in my opinion) would be either in the loader or some other project-specific file. (You may recall we already discussed this Paulo). What if the user has multiple projects each requiring different config settings?
Simply set the project-specific settings for each project in each project loader file using the set_logtalk_flag/2 directive/built-in predicate. The project loader files are in fact the most appropriated place to store project-specific settings.
Parker wrote: Also updating Logtalk shouldn't lose the project-specific information (I know it is backed-up).
Updating Logtalk never loses project-specific information, only resets default compiler flag values. Any customizations the user might have applied to the config files are backed-up when updating. If you want to avoid re-applying config file customizations when updating just use (whenever possible; see below) per project loader files to specify project-specific settings.
Parker wrote: Just an idea: perhaps the config file could be split up into:
...
Splitting the config files in two would duplicate the files a user might need to edit. Besides complicating the system, not all predicates in the config files are clear cut installation-wide or mutable settings. See e.g. the predicates for dealing with Prolog proprietary directives. The current config files deal with the most common ones but the user may also want to define his own processing. This would imply declaring several config file predicates as multifile, which is problematic as half of the supported Prolog compilers either don't implement the multifile/1 directive or have buggy implementations.

One thing that can and will be improved is the manual section on loader files, specially regarding project-specific settings. Thanks for your feedback.
Paulo Moura
Logtalk developer

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: less verbose compiler messages

Post by Paulo Moura » Thu Feb 26, 2009 1:27 pm

joerg wrote:I could not reproduce the error with your file j.lgt either. It seems that the file has to contain at least an object definition.

The following code was sufficient to produce the error on my system:
...
Replaced the contents of the "j.lgt" file with your code. Still unable to reproduce the problem (tried with both SWI-Prolog 5.6.63 and 5.7.6 on MacOS X 10.5.6). Can you check the time stamps of the "j.lgt" and "j.pl" before and after correcting the syntax error and trying to repeat the compilation?
Paulo Moura
Logtalk developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest