Re: [] \= '[]' (was Re: Ann: SWI-Prolog 7.1.0)

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 11/26/2013 04:50 AM, Richard A. O'Keefe wrote:

> Making [] not be an atom might (MIGHT!) make bad programming
> practices easier to patch into "working", but it would make
> meta-programming so much more complicated that it couldn't be
> excused.
>
> A typed Prolog exists.  It's called Mercury.  It works very well.

One point is that Prolog is an untyped language. The advantage of that
is that it allows for creating all sorts of ad-hoc `good looking' data
structures that fit the problem. However, this advantage disappears if
you have no runtime type information to see what type you are dealing
with. In that case, the only thing you can do is act as if it were a
typed language and make ugly looking explicitly typed datastructures.

There is a simple QED for [] \== '[]': it has proven to break extremely
little and the things it did break were mostly broken already (just in a
more subtly way).

The only practical thing it breaks is foreign code doing ATOM_nil =
PL_new_atom("[]"). That even affects little code as the C API already
provides operations such as PL_unify_nil() and PL_put_nil().  It now
provides the macro ATOM_nil, which in V7 is only a true atom when
--traditional is used.  In V7 mode it still cooperates with all
atom functions because [] is a `blob' and atoms are also blobs.

	Cheers --- Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.