On 06/03/2016 03:34 PM, Markus Triska wrote:
> Hi Wouter,
>
> Is it not possible to automatically clean huge quantities of Prolog
> code?
>
>
> This is likely what everyone who first hears about such issues would
> think and even start doing. It is certainly what I first thought when
> hearing about these problems. However, it unfortunately breaks the
> foremost principle of any archiving to retrospectively change the
> collected data, and for this reason the Prolog system or a compatibility
> layer should instead be made to work with the original, unchanged data,
> which is stored in an ISO conformant way.
>
> Note that even if this elementary constraint were removed and we decided
> to arbitrarily change the hitherto collected data to accomodate syntax
> quirks of other systems, suppose there are mistakes in the conversion:
> This would with certainty only complicate and execerbate the situation
> further, since it may subtly destroy internal properties of the data,
> and create further difficulties in later testing and debugging. If some
> mistakes are later found, is it time to recheck the conversion process,
> or maybe time to debug some completely different functionality?
You are exaggerating. If you have a Prolog system A that is guaranteed
to read the terms correctly (I doubt any system can guarantee that unless
you never upgraded this system; also SICStus started with what was
common in the late 80s and moved to ISO in several steps) and a system
B that must read the same data consistently it is easy enough to setup
a validation chain:
- A reads a term and writes it using write_canonical, possibly
with some tweaks. Another format might do as well.
- B reads the same term and the one in the secondary format and
calls variant/2 on them.
I think this is sufficient to make sure B can read the term and that the
structure is unchanged. You may have problems with quoted atoms that are
consistently misrepresented, but it shouldn't be too hard to extend the
scheme to get this right too. For example by changing all atoms into a
list of character codes and do the same trick.
That creates a setting where you can reliably change the representation
as well.
> The situation may be simpler in other Prolog applications, for example
> if the stored terms do not touch many corner cases of the ISO standard.
Normal production programs are generally less weird indeed.
> In GUPU though, we see the collected works of thousands of people who
> start learning Prolog, and you would be surprised of the huge number of
> corner cases these examples trigger in the underlying Prolog system's
> parser.
I don't really see why a ported GUPU should be able to read all work
done by all past students in the first place, let alone with 100%
reliability. The above scheme will do the trick however.
> For such reasons, a strong requirement for a complete GUPU port to a
> different Prolog system is that system's ability to correctly parse the
> hithereto collected vast number of (sometimes very strange) Prolog
> terms. In fact, for Ulrich, correctly parsing the existing data is a
> prerequesite to even start working on the port. Until then, I hope that
I'll stick with correct language ... Ulrich's only purpose of this is to
enforce strict conformance with the ISO standard. If this is fixed he
makes up a story why he can't start because of some other mostly
irrelevant issue is the problem.
Getting Prolog to round trip write/read using operators is really hard.
Running SWISH/Pengines has found several issues with that. Fixed one
today, where a.(;) was written as a. (;). Without using operators it
should be much easier.
SWISH/Pengines became in part realistic due to Ulrich's zillion bug
reports targeting stability issues for code no sane person would write,
and which I deemed often unimportant back then. It was not a big
priority, but it was great to have at the moment Torbjörn Lager came
along with his Pengines idea.
Cheers --- Jan