The history file is determined by dir_history_file/2 in library(prolog_history). The name is not a hash, but the base32-encoding of the absolute file name. Upper or lower case should not matter. The predicate is bi-directional, so you can find the project directory from the file and the other way around.
Dealing with the old history is probably something that should be fixed. Should not be too hard. It will write in the new format though, so you cannot jump forward and backward easily. The libedit format uses a bit proprietary encoding of characters that is not easy to handle without libedit (at least, not for non-ASCII).
If you want to share the init.pl file, use e.g.,
:- if((current_prolog_flag(version, V), V >= 90333)).
<code>
:- endif.
The history is saved on program exit. How do you terminate Prolog? I normally use Ctrl-D (end-of-file) in the console. That seems to work fine. Note there is a flag save_history that should be set to true. If it is not, something is wrong ā¦
Thanks! I missed that predicate, and the entire library too. Iāll go have a look.
I think if the history is only (easily) backwards compatible nobody will complain. I sure wonāt. If I can get my old history in the new version thatās all I need. I think for most people theyāll tend to upgrade monotonically, as it were, but of course thatās something for the community to discuss.
I have two main ways that I usually terminate Prolog:
enter ?- halt.
Cause a catastrophic error.
Iām used to losing the last few lines of history when 2. happens.
I got the save_history flag set to true in v.9.3.24 and in v.9.3.33.
Btw, forgot to say:
Yeah, I think thatās nice to have
Edit: Actually, I think I didnāt understand what you mean by ānumbered history accessā. You mean by !<number>?
Btw, I noticed that in some SWI versions you get a number at the start of a new prompt line. I mean that if a query terminates and then the listener returns to the ?-, thereās a number at the start of the line like 2 ?- . I think I only see that in the OS terminal sessions, not in the IDE, but at this point Iām a bit confused about which version does what so Iād have to check, sorrry!
Is that query numbering related to the lines in the history file also?
Probably a lot of it should be rewritten. There is too much history in the history implementation Now everything seems to have a solid common ground on all platforms, so we can delete and simplify a lot of stuff.
Thanks. Iāll check that out. Ctrl-D is shorter and (AFAIK) works.
History ⦠Before all this began and commandline editors were not common, history was based on storing commands in the Prolog database and allow reused using !<expr>. Then commandline editors came into place. By default, the commandline editor takes over and !!, etc are gone. Using
:- set_prolog_flag(history, 50).
Both are enabled and kept in sync. Given the current state it might be better to remove the old pure Prolog history and integrate !! expansion with the commandline editor. That would remove quite a bit of very old code
Hey, I wonder if I managed to confuse you with my awful sense of humour. I realise that my previous comment could be interpreted as saying that after halt I get a ācatastrophic errorā. What I meant was that I usually exit Prolog with halt, but sometimes I manage to crash the console so I āterminate Prologā that way instead. I donāt think Iāve ever seen the console crash after halt.
I was not confused Actually, there is a problem with halt executed in the context of the Epilog consoles. Try
swipl-win -g "mygoal,halt"
That does crash I know why, but I still have to find an elegant solution.
P.s. Todayās Windows binaries give you a native file dialog for the Epilog file related actions. Works (for me) on Windows-11, MacOS and Fedora Linux using Gnome.
Oh. OK, yeah, that crashes. Funny thing, Iāve seen something like that before but I think it was exit status 4. It happens occasionally but Iām not sure when.
Iām confused now why I said that because the file dialog hasnāt changed at all, itās still what I think is the 30-year old XPCE dialog. Sorry to upload an image but just to be clear, this is what the dialog looks like:
Thatās the new-file dialog in the editor, accessed by File > New⦠> Browse.
Thereās also a ānewā item in the console menu: File > New and while that opens a Windows Explorer window, it now gives me an error. I had to copy it manually because after I click the save or cancel button in the explorer window, SWI crashes:
31 ?- ERROR: [Thread main] @235576895175/epilog_frame: frame<-{open,save}_file: dialogg: An attempt was made to reference a token that does not exist.
This is with the latest stable version, 64 bits 10.1.5 on Windows.
Edit: also happens with the latest build on windows. Iām on widows 11 pro 64 bits.
Hereās something else. With the latest stable build for windows, when I click on the āFileā menu in the editor (not the console) I get this message at the top-level:
33 ?- XopenImage(@ms_left_arrow_image/image)
In fact this seems to happen with every menu item in the editor, but only the first time any item is clicked. So if I click āNewā I get the output above, then if I click āCompileā thereās no output.
Calling the SDL file dialog interface takes different parameters and not all places have been updated. At least the 30 year old thing still works
I see. This worked. Still works fine on Linux and MacOS. The message does not come from Prolog/xpce but from Windows and seems to address some security limitation. Iāll try to look into this ā¦
Meanwhile, Iām starting to worry youāre gonna want to kill me but thereās something else changed in the new environment.
Before the switch to epilog, I could CTRL+arrow key at the console and jump between āwordsā. This is no longer possible on windows, where CTRL+arrow key does nothing, and I have to slog through long queries with just the arrow keys one character at a time.
Thatās the console. On the command line, I get a series of ;5D escapes and no movement.
I get the same behaviour on linux, or rather WSL running Ubuntu 22.04.
SWI version on windows: 10.1.4-36-gec0988dab-DIRTY
SWI version on Linux: 9.3.20-11-g96e0fabbd
Can I do something about this? Thatās just the shell not recognising escape sequences, no?
Yes. This message is rather innocent though. The only consequence is that pullright menus show no arrow to indicate there is a pullright.
Well, I think you are at a safe distance not to worry too much Improving the user experience is (I think) quite important.
That is because the command line editor is now based on libedit rather than being a Windows GUI application. There seem to be a half-baked standard to pass modifiers using escape sequences. But, libedit does not implement this (which is why you see part of the uninterpreted escape sequence) and Epilog does not send it. The latter is surely quite easy to add, but not very useful without extending libedit. At some point Iāll consider that.
Meanwhile, libedit accepts Emacs sequences, so Alt-b and Alt-f (or ESC b and ESC f) move backward or forwards over a word. Also useful are Ctrl-A and Ctrl-E that move to the start or the end of the command.
That is really serious. It seems this was introduced by moving from SDL 3.2 to SDL 3.4. I am now trying to see whether claude can come with a work-around. It seems complicated It it fails there seem to be three ways out
Revert to xpceās native file dialog
Switch back to SDL3.2 and report an issue with SDL. This is a little complicated though as it requires building SDL3 for Windows on Linux or switch back to Fedora 42. But, that is nearly EOL and switches back to an older GCC that produces a slower Prolog
Bypass SDL3 for the file dialog and call the native Windows file dialog. That is how it used to be, but means more Windows specific code, something I wanted to get rid of
After about 15 minutes and endless commands, Claude indeed managed to nail the issue. It is a bug in SDL3.4, reported as `SDL_ShowOpenFileDialog`'s `default_location` handling of multiple levels of missing paths causes `callback` to be invoked twice on Windows (SDL 3.4.2) Ā· Issue #15194 Ā· libsdl-org/SDL Ā· GitHub. There is a PR for fixing this. Claude however managed to find a dirty but simple and effective work around. Sometime I want to throw the AI through the window, but this time I am pretty impressed and it saved me a lot of annoying work. Note that I started using ChatGPT. This failed miserably finding the actual cause as it got on the wrong track due to the misleading error message. It then suggested several work arounds for something that was not the problem, so it got nowhere.
P.s. Triggered building the daily, so the last (March 12) should be ok.
Thanks, Jan. I got the daily build (10.1.5-2-gc829d651e-DIRTY)) and Iām trying it now. Seems like I managed to get it to freeze by clicking around the File > New dialogue, but that happened only once, otherwise everything seems to be working OK now, no error and no pullright menu message.
I also tried the Esc/Alt-b/f thing and it works so thatās good, I can get used to that. At the cost of getting Emacs thumb
Whatās the difference? I run Ubuntu on WSL but I dual-boot windows with Fedora on my main machine. What differences can I expect to see there?
Between what and what? Fedora 42 uses SDL 3.2 and GCC 14 and Fedora 43 SDL 3.4 and GCC 15. We do not use any feature specific to SDL 3.4, but they changed the way the File Dialog is implemented for Windows and introduced a bug. GCC 15 produces somewhat faster code for Prolog. The SDL bug will probably hit us for a while as the fix is not yet in the main repo and Fedora 44 will be out soon.
SWI-Prolog build for Windows is created by cross-compiling using Fedora (in a Docker container). Originally I used Ubuntu for this, but Fedora has more ready to use dependencies for MinGW and more up-to-date compilers.
Thanks! I meant the difference between Fedora and Windows. I guess I could have just booted it up and found out. I think Iām on Fedora 42 btw, probably need to update at some point.
For running SWI-Prolog? From version 10, both versions pretty much have the same functionality. Running pure Prolog code has about the same performance. Thread management, I/O and graphics are a lot faster on Fedora. Not sure how much of that is lost by the WSL layer. My new dev machine is dual boot. The Fedora version feels a lot snappier than the Windows 11 version and text rendering is clearer.
Then there are some subtle differences in which predicates can be interrupted using thread signals and Ctrl-C. The Linux version used to be much more stable, but the work by @mgondan1 and @EricGT recently have fixed many issues in the Windows version.
@jan Iāve been thinking about this comment I made in an offhand manner last time and itās made me feel uncomfortable. I donāt want it to sound like I donāt respect your time. I guess itās no secret that I donāt like LLMs but Iām glad that AI helped you save time. Iāve watched you for over a decade that Iāve been using SWI-Prolog and youāre like a bug-killing machine, I guess the result of having worked on this project for⦠isnāt it 30+ years now? So I would always think that if an AI can find a bug in 15 minutes, you can find it and squish in 5. But I guess this time it was something completely unrelated to SWI.
Anyway I didnāt want to give the wrong impression. I hope you know I respect and admire your work. Sorry if that sounds cheesy. Iām a very cheesy person, but more to the point Iāve had the time of my life since 2017, when I started my PhD studying ILP, and none of that would have been possible without your work on SWI. Because if I needed to write something like SWI myself to run my ILP algorithms, I could never do it. I would have ended up with some shitty academic prototype of Prolog just stable enough to write my papers on, and nothing more. SWI is an industrial-strength Prolog implementation and I thank my lucky stars that I started my PhD (not to mention, learned to program at all, much earlier than that) at a time when it existed.
So, I hope I didnāt offend you with my stupid joke. I have a weird sense of humour. Some people will say I donāt have a sense of humour.
Not at all Note that besides a bug killing machine, Iām also a bug generator
And I use LLMs. Mostly because I want to understand what they can do and how I can best make use of them. Iām not sure it saves me time. Sometimes it clearly does, sometimes it clearly costs time as the LLM keeps looking in the wrong direction. And, sometimes the LLM can do work that I might be able to do just as fast, but which is very boring.
All in all, they are an āinteresting companionā Considering what they could do a year ago they improve incredibly fast.