appliedlogicsystems / alsprolog Goto Github PK
View Code? Open in Web Editor NEWALS Prolog Compiler & Development Environment
Home Page: https://alsprolog.com
License: MIT License
ALS Prolog Compiler & Development Environment
Home Page: https://alsprolog.com
License: MIT License
Steps:
As expected, the source file will be auto-loaded for viewing.
However, on the very last line of the file, an extraneous number is written at the beginning of the line, usually a single digit integer. This also occurs if instead of trace, one issues a spy command against any call in the source file.
This does not occur if the source file is loaded via File > Open.
Explore fleshing out the code for the Application/Gui tools Application Gui Generator, Setup New Application Framework (buttons under Tools in ale_menu.tcl)
Tom reported the make fails with missing X11 header for Tcl/Tk:
clang -m32 -std=gnu99 -O0 -MMD -Wall -Wmissing-prototypes -Wwrite-strings -Wnested-externs -Wpointer-arith -isystem /usr/X11/include -I /System/Library/Frameworks/Tk.framework/Versions/Current/Headers/ -I ../../alsp_src/port -I ../../alsp_src/unix -I ../../alsp_src/generic -I ../../alsp_src/smath -DUNIX -DUNIX_DARWIN -DPORT -c -o tcl_interface.o ../../alsp_src/../tcltk_interface/common/tcl_interface.c
In file included from ../../alsp_src/../tcltk_interface/common/tcl_interface.c:17:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^
1 error generated.
In alspro:
ALS Prolog (Threaded) Version v3.1.24-266-g46a7be3-dirty [darwin]
Copyright (c) 1987-2015 Applied Logic Systems, Inc.
?- assert(a(1)).
yes.
?- spy(a/1).
Spy point set on a/1 in modules [user].
yes.
?- list_spypoints.
Spypoints:
user:a/1
yes.
?-
In alsdev:
ALS Prolog (Threaded) Version v3.1.24-266-g46a7be3-dirty [darwin]
Copyright (c) 1987-2015 Applied Logic Systems, Inc.
?- assert(a(1)).
yes.
?- listing.
% user:a/1
a(1).
yes.
?- spy(a/1).
Error: Instantiation error.
?-
It might also be nice to add a -h or --help option to alspro, which could give a terse description of alspro arguments options and also point to docs elsewhere.
They stop at "Compare"
Cygwin packages, Ubuntu
Prolog > Consult: load queens.pro
Tools > Debugger
Click on Debugger console
Tools > Spy
Switch Modules to user (should be default)
In Prolog Env console, type spy all_queens.
Result: Console shows yes. , but no change to Spying On column of Spy panel.
Click Refresh Preds in Spy panel;
Result: all_queens/0 now shows in Spying On column.
Desirable enhancement:
all_queens/0 should show in Spying On column without need to click Refresh Preds.
Alsdev works fine from core/unix/darwin, but fails (dead shell) when run from packaged dir (unix/darwin/als_prolog)
The file ALSProlog/core/alsp_src/builtins/blt_dvsh.pro is present in the repository, but when a (unix) build is carried out, blt_dvsh.pro is not present in ALSProlog/unix/darwin/als-prolog/alsdir/builtins. This may be related to Issue #8 [alsdev: Tools > Debugger too narrow/too big button font], since at present, making changes to the global default geometry for .debugwin [set proenv(.debugwin,geometry) 600x300+300+0] in ALSProlog/core/als_dev/alsdev/alsdev.tcl does not seem to have any effect on the debug window. In contrast, changing the global default for font size [set proenv(.topals,font) {user 14 normal}] has effect when the main alsdev window opens.
Prolog > Load Project
Select ~examples/visual/twigs.ppj
On Project Spec panel, click Save
Result:
Application Error window opens; Details:
prolog exception: error(type_error(atom,[id.pro,hickory.pro]),[builtins:atom_codes([id.pro,hickory.pro],_68645)])
prolog exception: error(type_error(atom,[id.pro,hickory.pro]),[builtins:atom_codes([id.pro,hickory.pro],_68645)])
while executing
"prolog call $proenv(dflt_mod) send -number $proenv($Obj) -atom $Msg"
(procedure "send_prolog" line 3)
invoked from within
"send_prolog als_ide_mgr save_project"
(procedure "save_project" line 2)
invoked from within
"save_project"
invoked from within
".project_1462824030_0.buttons.save invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 23)
invoked from within
"tk::ButtonUp .project_1462824030_0.buttons.save"
(command bound to event)
als_help.html works fine in Safari, but clicking on topics in Chrome/FF/Edge causes the topic to open in a new tab, rather then the topic frame.
When Tools > Debugger is opened , all buttons across the top are too narrow for their labels. The font on the labels is approximately right, so if possible, the window should be widened and the buttons widened.
Work out how to connect blt_pckg.pro:save_image(ImageName, Options) to the Addl Project info panel:Make Executable button, and flesh out Add Lib File / Delete Lib File.
The following problems with the Break Handler package occur in both alspro and alsdev.
Create a file t.pro containing f :- write(foo), f. [Or just assert that clause].
Execute: alspro t.pro
Run: ?-f. Immediately hit ^C to interrupt the spew.
You get the break handler:
Break Handler
------------------------
a - Abort Computation *
b - Break shell
c - Continue
d - Debug
e - Exit Prolog
f - Fail
p - Return to Previous Break Level
s - Show goal broken at
t - Stack trace
? - This message
Break(1) >
Items a-e, p work correctly. Option f will work correctly for this case [f :- write(foo), f.], but below we show a different case in which it fails.
Options s,t fail, showing bits of the underlying interrupt handler code (typically different bits each time this is carried out):
Break(1) >s
Break at: sio:_A is 866-0
Break Handler
------------------------
a - Abort Computation *
b - Break shell
c - Continue
d - Debug
e - Exit Prolog
f - Fail
p - Return to Previous Break Level
s - Show goal broken at
t - Stack trace
? - This message
Break(1) >
Break(1) >t
(1) builtins:stack_trace(1)
(2) builtins:
break_handler(stack_trace,sio,'$is_delay_var'(zipper),
als_shl_mgr(als_shl_mgr,builtins,1...))
(3) builtins:catch0(builtins,?,?)
(4) builtins:breakhandler(sio,'$is_delay_var'(zipper))
(5) sio:wd(zipper,1200,400,nospace,nospace,[_A|_B],_B...)
(6) sio:wd(zipper,400,?,[],?)
(7) sio:
write_term0(
stream_descriptor('',open,console,'standard output',[noinput,...],
false...),
zipper,winfo(false,false,false,true...))
(8) user:f
Break Handler
------------------------
To demonstrate option f failing, create a file t2.pro containing the following:
a :- b.
b :- c.
c :- d.
Execute alspro t2.pro
Run (and interrupt with control-C) at the indicated point, getting the printed result:
?- trace a.
(1) 1 call: user:a?
(2) 2 call: user:b?^C
Break Handler
------------------------
a - Abort Computation *
b - Break shell
c - Continue
d - Debug
e - Exit Prolog
f - Fail
p - Return to Previous Break Level
s - Show goal broken at
t - Stack trace
? - This message
Break(1) >f
Error: System error: sio:get_line0(debugger_input,_A,_B)
How should Linux release be wrapped?
Possibly of use:
http://0install.net
http://www.comptechdoc.org/os/linux/howtos/linux_htmakepackages.html
http://packaging.ubuntu.com/html/packaging-new-software.html
http://searchenterpriselinux.techtarget.com/tip/Creating-RPM-packages-in-Linux
After closing all the error windows for Issue #6, all items on the menu bar are disabled in the sense that each menu will pull down, but all entries in that menu are grayed out.
List of installers:
https://en.wikipedia.org/wiki/List_of_installation_software
Choose File > New, type something, and then choose Edit > Clear. Nothing happens.
However, it some of the typed text is selected, that is removed when Edit > Clear is chosen.
Note: this also applies to the main alsdev console as well as the debugger console.
Should change 'Clear' to 'Clear Selection'.
A simple loop with a system/1 call can't be interrupted with Control-C:
r :- system('sleep 1'), r.
Expected Result: Control-C should interrupt the loop and enter the break-handler.
There's an old version of the ALS examples in core/alsp_src/test/als_exmp/
I would have just deleted it, but there are some extra files (animals.pro, count.pro
), and a fair number of differences.
@kenbowen can you review the diffs, and determine if anything needs saving, or if it can all be deleted?
Here's the command I used at the top of the tree to view the diffs:
diff -wB -ruN core/alsp_src/tests/als_exmp/ examples/als/ | less
The error raised is:
prolog exception: error(existence_error(procedure,alsdev:check_reload_consults),[alsdev:check_reload_consults])
prolog exception: error(existence_error(procedure,alsdev:check_reload_consults),[alsdev:check_reload_consults])
while executing
"prolog call alsdev check_reload_consults"
(procedure "do_the_debug_flag" line 5)
invoked from within
"do_the_debug_flag"
invoked from within
".debugwin.debug_status.source_trace invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 23)
invoked from within
"tk::ButtonUp .debugwin.debug_status.source_trace"
(command bound to event)
Explore adding a command line editing library to the ALS Prolog shell (blt_shl). GNU Readline is not suitable because it is licensed under GPL instead of LGPL, which would be incompatible with the MIT license. Searching for “command line editing libraries” produces definite possibilities:
-- Tecla (http://www.astro.caltech.edu/~mcs/tecla/libtecla-1.6.3.tar.gz) (like UNIX tcsh shell) Variant of MIT license
-- antirez/linenoise (https://github.com/antirez/linenoise) Looks compatible with MIT license
-- Editline Library (lib edit) (http://thrysoee.dk/editline/) BSD-style license
Throws Application Error window - Error: invalid command name "getDirectory"
Details:
invalid command name "getDirectory"
invalid command name "getDirectory"
while executing
"getDirectory"
(procedure "set_directory" line 3)
invoked from within
"set_directory"
("uplevel" body line 1)
invoked from within
"uplevel $a"
Adapt the existing cref code from alspro/library to work in alsdev (using the commented-out Cref button under Tools in ale_menu.tcl)
The popup only has info about Tcl/Tk
Exiting via ?-halt on the alsdev console window raises a confirmation dialog, and if Yes is chosen, the current window sizes, positions, etc are written to $HOME/.alspro. Exiting via menu bar > alsdev > Quit alsdev should do the same, but doesn't: There is no dialog raised, and nothing is written to $HOME/.alspro.
Steps:
spy all_queens/0.
Result: No change in "Spying On" column of Spy window.
Expected Result: all_queens/0 should appear in "Spying On" column of Spy window.
Prolog > Load Project
Select ~examples/visual/twigs.ppj
On prolog console, type halt.
Dialog “Save Project?” opens; click Yes;
Result: Tcl error window opens with:
error(
tcl_error(
prolog exception: error(type_error(atom,[id.pro,hickory.pro]),[builtins:atom_codes([id.pro,hickory.pro],_70034)])),
_A)
Also, a blank Tk window opens with title: tk #2
Drop the Close button (next to Save). Make the standard window close button (red, top left) check whether anything in the project specification (including Addl Project info) has changed, and if so, prompt the user about first saving before closing.
The font used for the console/editor is very small compared to the font size used in current OSes.
Note: Ultimately adding font settings (#5) will fix this, but a simple stop-gap measure would be to find a way in Tcl/Tk to set the font size to a system-defined "normal" size (for monospace text)?
The following succeeds (silently consults queens.pro):
alspro '/Users/ken/ALS/GitHub/ALSProlog/examples/als/queens.pro'
The following fails:
alspro -s '/Users/ken/ALS/GitHub/ALSProlog/examples/als' 'queens.pro'
ALS Prolog (Threaded) Version v3.1.24-266-g98ebb5a-dirty [darwin]
Copyright (c) 1987-2015 Applied Logic Systems, Inc.
Error: Operation attempted on object of type source_sink which does not exist.
Operation attempted on: 'queens.pro'.
Usually, there are two issues with read-only example files:
Typically, to make example files more discoverable a program will add some helper UI. For example, in Scratch, there is an example button in the File>Open dialog. In Xynk, there is a File>Examples>* sub-menu that lists all examples (stored in the .app bundle).
For alsdev, a simple solution would be to add a menu item like File>Examples..., which would just present the standard open-file dialog, but always set to browse /usr/share/doc/als-prolog/examples (or wherever).
Once a read-only example file is found and opened, the problem is what to do with modifications. Rather then display a write-denied error message, programs like Scratch and Xynk will offer to save the modified example somewhere else. Basically, the Save command always triggers Save-As, often defaulting the location to a standard "Documents" folder in the user's home directory.
For alsdev, it might be necessary to add a flag to any file window opened from examples, to signal that it should use Save-As if it needs saving.
With the above solutions, tutorial docs became much easier and consistent. Because the examples have some helper UI, docs just need to say "open queens.pro from File>Examples..." and the user will find it every time. Because the examples are read-only, a user following a tutorial is always guaranteed to get a pristine copy of the example, even if they previously played around with it (and broke it).
[ note, the above applies to the alsdev GUI. Command-line users of alspro just need pointers to /usr/share/doc/als-prolog/examples in the man page, etc. They can just cp -r
the examples if they want to tinker with them. ]
Create a “pretty” stack trace mechanism which focuses on display of the user code, and which would be made available in both the standalone break package and the debugger as option “u - pretty stack trace”. The code should be as close to common as possible between the standalone break package and the debugger; it should emulate (as near as possible) the steps taken by the debugger to avoid showing (noshow) both debugger internals and the internals of builtins. Cf. the closed #37 for concerns.
In alsdev, the debugger with source trace fails in various ways, although #1 below shows a core basic way that it works. Items #2-4 show ways that it fails.
Below, consult = click Prolog > Consult.
Note that the state (checked/uncheckekd) of the source trace box in the debugger window is saved on exit from alsdev.
#1: Everything succeeds.
1a. alsdev; consult queens.pro; click Tools > Debugger; comes up with source trace checked; ?- trace all_queens
Result: queens.pro source window opened, and 1st call (InitTime is cputime) is highlighted in blue.
Clicking click/skip works as expected, including source trace.
1b. Click Abort;
Result: Console shows: Error: Execution aborted. with prompt (?-) below.
queens.pro source window still open, with same blue highlight.
1c. In console, execute ?- trace all_queens. (again). Result: same as 1a. Click Abort. Same as 1b.
1d. In console: ?- spy all_queens. Result:
Console: yes. With new prompt ?- below. Debugger: Spy points set on: [user:all_queens/0]
1e. In console: ?- all_queens. Everything working as expected.
halt alsdev.
#2: Spy causes Error Popup:
2a. alsdev; consult queens.pro; spy all_queens.
Result:
Debug win opens, but then on top of it:
Error window. Message:
prolog exception: error(domain_error(line_length,0),[sio:set_line_length(stream_descriptor(,open,tk_win,.debugwin.text,[noinput|output],false,-8,,gui_debugger_output,ti(shl_tcli,WaitForLine.debugwin.text),,true,0,wt_opts(80,4,nonflat),[],snr_code,text,eof_code,true,0),0)])
prolog exception: error(domain_error(line_length,0),[sio:set_line_length(stream_descriptor(,open,tk_win,.debugwin.text,[noinput|output],false,-8,,gui_debugger_output,ti(shl_tcli,WaitForLine.debugwin.text),,true,0,wt_opts(80,4,nonflat),[],snr_code,text,eof_code,true,0),0)])
while executing
"prolog call debugger set_debugwin_width -number $FM -number $WWD"
(procedure "debugwin_configure_event" line 5)
invoked from within
"debugwin_configure_event .debugwin 1 1 .debugwin.text"
(command bound to event)
Halt aldev.
#3 Alt use of spy causes debugger interrupts ($dbg_apg) to show in trace:
3a. alsdev; consult queens.pro; click Tools > Debugger; debug win opens, with Source trace box checked.
Console: ?- spy all_queens.
Result: Console: yes/prompt ?- Debug win: Spy points set on: [user:all_queens/0].
Console: ?- all_queens.
Result:
queens.pro source window opens, but no highlighting.
Debugger win: 2) 2 call: user:$dbg_aph(16,949,959
Clicking creep: Trace is showing the debug interrupts:
py points set on: [user:all_queens/0].
(1) 1 call: user:all_queens
(2) 2 call: user:$dbg_aph(16,949,959
(3) 2 call: user:$dbg_apg(16,965,984)
(4) 2 call: user:_9495 is cputime
(4) 2 exit: user:2.92 is cputime
(5) 2 call: user:$dbg_apge(16,965,984)
(6) 2 call: user:$dbg_apg(16,994,1021)
#4 Clicking un-checked source trace box raises error popup:
4a. Unclick the Source trace box; halt alsdev;
restart alsdev. click Tools > Debgger; opens debugger window, source trace box now un-checked
Click source trace box; Result: Error window opens:
rolog exception: error(existence_error(procedure,alsdev:check_reload_consults),[alsdev:check_reload_consults])
prolog exception: error(existence_error(procedure,alsdev:check_reload_consults),[alsdev:check_reload_consults])
while executing
"prolog call alsdev check_reload_consults"
(procedure "do_the_debug_flag" line 5)
invoked from within
"do_the_debug_flag"
invoked from within
".debugwin.debug_status.source_trace invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 23)
invoked from within
"tk::ButtonUp .debugwin.debug_status.source_trace"
(command bound to event)
Continue by clicking OK on error window.
Result: source trace box now checked
consult queens.pro. everything ok.
Execute ?- trace all_queens. Result as in 1a.
It would be useful if Prolog programs could be run from shell scripts. For example:
#!/usr/bin/alspro
:- write('hello world'),nl.
This could be allowed by modifying the Prolog pre-processor to ignore lines starting with the shebang: #!
It has at least the following failure [probably a bunch more]:
?- animal.
Please describe the animal.
Has it hair? yes.
---the animal is a mammal by rule 1
Does it eat meat? no.
Has it pointed teeth? no.
Has it hoofs? no.
Does it chew cud? no.
Done.
Run again? yes.
Please describe the animal.
Has it hair? yes.
---the animal is a mammal by rule 1
Does it eat meat? no.
Has it pointed teeth? yes.
Has it claws? yes.
Has it eyes pointing forward? yes.
---the mammal is a carnivore by rule 6
Has it a tawny color? yes.
Has it dark spots? yes.
---the carnivore is a cheetah by rule 9
Done.
In alspro TTY shell, attempting to Exit Prolog from Break Handler just returns to top level of Prolog shell. [Most likely, something similar in alsdev].
For example:
?- read(X).
^C
Break Handler
------------------------
a - Abort Computation *
b - Break shell
c - Continue
d - Debug
e - Exit Prolog
f - Fail
p - Return to Previous Break Level
s - Show goal broken at
t - Stack trace
? - This message
Break(1) >e
Error: No previous level!!
Error: Execution aborted.
?-
Example:
$ alspro
ALS Prolog (Threaded) Version v3.1.24-210-g0a542e5 [darwin]
Copyright (c) 1987-2015 Applied Logic Systems, Inc.
?- trace(true).
(1) 1 call: user:true?t
----begin stack trace----
Error: Operation attempted on object of type procedure which does not exist.
Operation attempted on: debugger:deb_stack_trace(1,1).
- Goal: debugger:deb_stack_trace(1,1)
- Throw pattern: error(
existence_error(procedure,
debugger:deb_stack_trace(1,1)),
[debugger:deb_stack_trace(1,1)])
Main problem is the assumption that size_of(long) is 4 in lots of placing involving bit-twiddling of types, etc.
Make the Save button behave in a modern way: grayed-out, inactive when nothing in the project specification (including Addl Project info) has been changed, and make it become active when anything in the project specification (including Addl Project info) has changed.
After building the distribution package, do:
Result:
$ ./alspro
Warning: Command failed.
Expected Result:
alspro should run normally and present prolog shell.
Tools > Debugger
Click on Debugger console
Tools > Spy
In Spy panel (Predicate Information), the default module being spied upon (into) should be user;
In alsdev, the menu item Edit > Delete should only be active when there is a selection (standard behavior for native apps). Unfortunately, Tk doesn't have any build-in support for menu-enabling (i.e. syncing text selection state with menu enable states), so one would have to create a mechanism to do that.
Put it on the far right, aligned with [Re-Spy]. Clicking [Clear] will a) invoked Abort if any debugger trace (with or without source tracing) is under way (but leave the status of the source tracing checkbox as it is); and b) clear the debugger window.
Set up alsprolog web site as a repo in AppliedLogicSystems. Decide whether to host it on GitHubPages or on DH. Decide what should go onto / be said on the site.
Notes from Trello:
Ken:
Yes, GitHub Pages makes sense — was really just acknowledging that it’s currently at DH. At the moment, I can’t imagine sufficient complexity to warrant more than a page: one can always scroll down.
Chuck:
You should definitely give GitHub Pages a try. It should be simple to setup, and it will support push-to-deploy out of the box. If the site needs more then one page, then you can use the automatic Jekyll support (static site CMS using Markdown).
Switching back and forth will just be a DNS change (at least with the current static 1-page HTML).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.