Re: Ann: SWI-Prolog 7.1.0

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 11/22/2013 10:48 PM, Abramo Bagnara wrote:
>>   - functor() is valid syntax.  It produces a term that is distinct
>> >     from 'functor'.  The `block' operator '()' to hack this syntax
>> >     has been removed.
> ?- A1 = a(), functor(A1, a, 0), functor(A2, a, 0), writeln(A1-A2), A1 = A2.
> a()-a
> false.
> 
> This behavior is indeed very surprising for me... Is it deliberate?

Yes.  I tried changing functor/3 (and =../2), but the compatibility
consequences are too involved and often hard to debug.  Therefore I left
functor/3 and =../2 alone and added compound_name_arity/3 and
compound_name_arguments/3.  You need these if you want to do
term manipulation that is robust against a().  a() mainly plays
a role in user-defined functions on maps and special purpose
notation for DSLs.  This implies you mostly need to be aware
of this in some parts of the Prolog infrastructure (e.g,
goal expansion) and code that manages DSL expressions that use
this.

In my view, this is a notation that can make the representation
of some DSLs much more understandable and you don't need to use
it in other contexts.  That said, I like

	maplist(length(), ListOfLists, Lengths)

more than

	maplist(length, ListOfLists, Lengths)

	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.