less verbose compiler messages

Suggestions for new Logtalk features

Moderator: Paulo Moura

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

Re: less verbose compiler messages

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

I gave a wrong description of the problem: Editing and saving the file *does* make the problem go away. The reason why I thought that this was not the case is that I usually work with many Emacs buffers and in the cases in question I obviously forgot to save the relevant Emacs buffer. It seems that I am bit hasty today, sorry ...

On the other hand, if j.lgt contains an error and if the Logtalk compiler produces the file j.pl anyway (which my Logtalk compiler does) then loading j.lgt again will not lead to the same error message. Then Logtalk simply loads the corrupt file j.pl and, as a consequence, produces strange error messages. (See Logtalk session given below.)

But, obviously, the problem would go away, if Swi halted on any error.

Code: Select all

schuster@lakonia:~/tmp> ls
j.lgt  load.pl
schuster@lakonia:~/tmp> pl
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.6.64)
Copyright (c) 1990-2008 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- consult(load).
%  /home/schuster/bin/logtalk/lgtsvn/configs/swi.pl compiled 0.01 sec, 22,720 bytes
%  /home/schuster/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl compiled 0.28 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

%         ERROR!    syntax_error(operator_clash)
%                   in file('j.lgt', 5, 4, 60)
%                   in file j.lgt, above line 9
ERROR: Unknown error term: error(syntax_error(operator_clash), file(j.lgt, 5, 4, 60))
Warning: Goal (directive) failed: user:logtalk_load(j)
% load compiled 0.29 sec, 600,608 bytes
true.

?- 

% halt
schuster@lakonia:~/tmp> pl
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.6.64)
Copyright (c) 1990-2008 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- consult(load).
%  /home/schuster/bin/logtalk/lgtsvn/configs/swi.pl compiled 0.01 sec, 22,720 bytes
%  /home/schuster/bin/logtalk/lgtsvn/integration/logtalk_comp_swi.pl compiled 0.21 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
%  j.pl compiled 0.00 sec, 288 bytes
% (0 warnings)
% load compiled 0.22 sec, 596,768 bytes
true.

?- test_object::test.
ERROR: Unhandled exception: Unknown message: error(existence_error(object, test_object), test_object::test, user)
?- 
Here is the content of load.pl:

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).
:- logtalk_load(j).

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

Re: less verbose compiler messages

Post by Parker » Thu Feb 26, 2009 2:26 pm

Paulo Moura wrote:
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.

One thing that can and will be improved is the manual section on loader files, specially regarding project-specific settings. Thanks for your feedback.
Yes, a manual (sub-)section on project-specific settings would be helpful. I'd be interested to see how a file with my preferred settings can be loaded so that it applies to all subsequent logtalk_load's in the project loader.

Cheers,
Parker
PS: apologies for being off-topic, my comment seemed more relevant when I first posted.

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 2:29 pm

joerg wrote: I gave a wrong description of the problem: Editing and saving the file *does* make the problem go away. The reason why I thought that this was not the case is that I usually work with many Emacs buffers and in the cases in question I obviously forgot to save the relevant Emacs buffer. It seems that I am bit hasty today, sorry ...
No problem. You actually found a problem that needs to be fixed (see below). Thanks for your bug report.
joerg wrote: On the other hand, if j.lgt contains an error and if the Logtalk compiler produces the file j.pl anyway (which my Logtalk compiler does) then loading j.lgt again will not lead to the same error message. Then Logtalk simply loads the corrupt file j.pl and, as a consequence, produces strange error messages. (See Logtalk session given below.)
You're halting the Logtalk/SWI-Prolog session between your compilation and loading attempts. One possible solution to avoid the problem in this case would be to delete the intermediate (and incomplete ) Prolog files whenever the compilation aborts with an error. I will look into it. The only problem I foresee is that not all Prolog compilers provide a built-in predicate for deleting a file.
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 6:52 pm

The bug with the "smart_compilation" compiler flag is corrected in r4714 for all back-end Prolog compilers that support a built-in predicate for deleting files and that throw an exception when read_term/3 finds a syntax error. Please test this development version and report back.
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 7:05 pm

Parker wrote: Yes, a manual (sub-)section on project-specific settings would be helpful.
The manuals included with the current development version already provide some guidance on using loader files to set project-specific settings. Suggestion for improvement are welcome.
Parker wrote: I'd be interested to see how a file with my preferred settings can be loaded so that it applies to all subsequent logtalk_load's in the project loader.
Not sure if I understand the problem here. If you load a file with your preferred settings, these will be applied to all subsequent logtalk_load/1-2 calls as long as the used loader don't override the settings. Note that the use of the set_logtalk_flag/1 directive in a source file have local scope. For a global scope, you need to call the set_logtalk_flag/1 built-in predicate within an initialization/1 directive.
Paulo Moura
Logtalk developer

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

Re: less verbose compiler messages

Post by joerg » Fri Feb 27, 2009 8:43 am

I tested the new version with Swi. It seems to work. Thanks.

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

Re: less verbose compiler messages

Post by joerg » Fri Feb 27, 2009 9:45 am

I also tested the new version with Yap. Seems to work.

By the way: In order to use Logtalk with Yap, I transformed my load_logtalk.pl into a load_logtalk.yap. This process was not totally straightforward and the fact that such things are necessary, if one wants to use Logtalk, might scare possible future users of Logtalk away.

Here is my load_logtalk.pl:

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).
Here is my load_logtalk.yap:

Code: Select all

load_logtalk :-
	consult('~/bin/logtalk/lgtsvn/configs/yap.pl'),
	consult('~/bin/logtalk/lgtsvn/compiler/logtalk.pl'),
	consult('~/bin/logtalk/lgtsvn/libpaths/libpaths.pl'),
	set_logtalk_flag(xmldocs, off),
	set_logtalk_flag(portability, warning),
	set_logtalk_flag(smart_compilation, on),
	set_logtalk_flag(report, warnings).

:- load_logtalk.
There are some differences that seem to concern Swi's and Yaps concepts of query vs. directive. But, apart from that, there are also Logtalk-specific problems: Why can't I simply replace '.../integration/logtalk_comp_swi.pl' with '.../integration/logtalk_comp_yap.pl' or at least with '.../integration/logtalk_yap.pl'. What is the use of '.../integration/logtalk_yap.pl', anyway? (When I trie to load it, I get an error: "Permission error: cannot read from $LOGTALKUSER"). Why is there a file '.../integration/swihook.pl', but no file '.../integration/yaphook.pl'?

There are probably good reasons why this is so. But someone who is just stopping by on the Logtalk web site, asking himself if object oriented logic programming might be the right thing for his specific problems, will probably not have the patience to create a Logtalk load script by trial and error.

Why not add some such scripts and/or example Logtalk sessions to the "Starting Logtalk"-part of the manual?

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 » Fri Feb 27, 2009 1:30 pm

joerg wrote: I also tested the new version with Yap. Seems to work.
The only problem I found so far is that you cannot use smart compilation of source files with ECLiPSE. The implementation of the ISO standard predicate read_term/3 in this Prolog compiler fails when finding a syntax error instead of throwing an exception!
joerg wrote: By the way: In order to use Logtalk with Yap, I transformed my load_logtalk.pl into a load_logtalk.yap. This process was not totally straightforward and the fact that such things are necessary, if one wants to use Logtalk, might scare possible future users of Logtalk away.
....
You want to use custom Logtalk startup scripts. That's fine, as long as you know what you're doing. Most users are happy to use the pre-built startup scripts on POSIX systems and the shortcuts in Windows systems that are available from the Start Menu.
joerg wrote: There are some differences that seem to concern Swi's and Yaps concepts of query vs. directive. But, apart from that, there are also Logtalk-specific problems: Why can't I simply replace '.../integration/logtalk_comp_swi.pl' with '.../integration/logtalk_comp_yap.pl' or at least with '.../integration/logtalk_yap.pl'. What is the use of '.../integration/logtalk_yap.pl', anyway? (When I trie to load it, I get an error: "Permission error: cannot read from $LOGTALKUSER").
Prolog compilers are different and Prolog portability is poor due to the lack of strong standards. Logtalk startup scripts hide those differences using the custom files in the "integration" directory. Mucking around with those files without a full understanding of the differences between Prolog compilers is a sure way to get into trouble.
joerg wrote: Why is there a file '.../integration/swihook.pl', but no file '.../integration/yaphook.pl'?
Because SWI-Prolog provides features (that Logtalk integrates with) that are not present in YAP or in any other Prolog compiler?
joerg wrote: There are probably good reasons why this is so. But someone who is just stopping by on the Logtalk web site, asking himself if object oriented logic programming might be the right thing for his specific problems, will probably not have the patience to create a Logtalk load script by trial and error.
As I stated above, most Logtalk users simply use the provided startup scripts. There is no need to create a Logtalk script by trial and error. The customizations that you're trying to do with the calls to set_logtalk_flag/2 can be easily performed by editing the config files (see the CUSTOMIZE.txt file provided with the Logtalk distribution) or by including the calls in project-specific loader files. Power users can, of course, chose to customize the provided scripts.
joerg wrote: Why not add some such scripts and/or example Logtalk sessions to the "Starting Logtalk"-part of the manual?
Did you notice the QUICK_START.txt file included with the Logtalk distribution? This file is also mentioned in the README.txt file, also included with the Logtalk distribution. Regarding the Logtalk user manual section "Starting Logtalk" the first paragraph reads:
Depending on your Logtalk installation, you may use a script or a shortcut to start Logtalk with your chosen Prolog compiler. On POSIX operating systems, the scripts should be available from the command-line; scripts are named upon the used Prolog compilers. On Windows, the shortcuts should be available from the Start Menu.
The script names are printed by the Logtalk installers for MACOS X, Linux, and Debian users during the installation process, together with other useful information. The Windows installer directs the user to the Logtalk program group in the Start Menu.
Paulo Moura
Logtalk developer

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

Re: less verbose compiler messages

Post by joerg » Fri Feb 27, 2009 3:37 pm

O.k. Thanks for all the hints. It is probably not Logtalk, but Prolog which is in need of enhancement (i.e. standardization).

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 » Fri Feb 27, 2009 6:29 pm

Paulo Moura wrote: The only problem I found so far is that you cannot use smart compilation of source files with ECLiPSE. The implementation of the ISO standard predicate read_term/3 in this Prolog compiler fails when finding a syntax error instead of throwing an exception!
Found a workaround that allows smart compilation of source files when using ECLiPSE as the back-end Prolog compiler. Committed in r4715.
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 » Wed Mar 04, 2009 8:19 pm

Parker wrote: Yes, a manual (sub-)section on project-specific settings would be helpful. I'd be interested to see how a file with my preferred settings can be loaded so that it applies to all subsequent logtalk_load's in the project loader.
For most Prolog compilers, it's quite easy to pass a goal in the command-line. From the "integration/NOTES.txt" file in the Logtalk distribution:
The Logtalk integration scripts accept command-line options, which are passed straight to the back-end Prolog compiler. For example (on a POSIX operating-system, using SWI-Prolog as the back-end compiler):

Code: Select all

     % swilgt -g "write('Hello world!'), nl"
However, keep in mind that the integration scripts already use the back-end
Prolog command-line option that allows a initialization file to be loaded
in order to bootstrap Logtalk. See the scripts files for details.
Thus a simple solution, assuming you have a file named "my_logtalk_settings.pl" with your personal settings, is to call e.g. the SWI-Prolog integration script using the command:

Code: Select all

     % swilgt -g "consult(my_logtalk_settings)"
Note that, for other Prolog compilers, the predicate to use may be other than consult/1. If the personal settings file is instead a Logtalk file then the command would be:

Code: Select all

     % swilgt -g "logtalk_load(my_logtalk_settings)"
Hope this helps.
Paulo Moura
Logtalk developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest