Re: Question about singleton variable names

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Thu 18 Jul 2002 11:00:14 AM GMT
Message-ID: <3D369FBE.A1FB9B7@icparc.ic.ac.uk>
"J.R. van Ossenbruggen" wrote:
> 
> However, read_term(+Stream, ?Term, [singletons(S)), returns
> also the variable names starting with '_' (e.g. _Foobar).

According to my interpretation of the ISO Prolog standard,
this behaviour is correct. It states that the list must
contain all non-anonymous variables which occur only once.
Anonymous variables are defined as the ones written as _ only.


> Since Logtalk uses the latter to warn me about singletons, this results
> in a lot of unwanted warnings.

A convention, like suppressing warnings for certain name patterns,
should be implemented by the caller of read_term. In this case,
it should filter out names that satisfy sub_atom(Name,1,1,'_').


> Is there a way to suppress the underscored
> variables in read_term(+Stream, ?Term, [singletons(S))?

No, and I don't think there should be one.

Paulo Moura wrote:
> I think that the ECLiPSe implementation of the singletons/1 option of
> the read_term/3 predicate should check the flag that you mention above
> and act accordingly. This will solve the problem. Is this a bug or a
> matter of flag scope?

I believe it is in general a bad idea to have the results of
built-in predicates vary with global flag settings.


-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Thu Jul 18 12:00:27 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:15 PM GMT GMT