Re: string_lower producing atoms

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 03/11/2014 02:53 PM, Michael Hendricks wrote:
> On Tue, Mar 11, 2014 at 6:02 AM, Peter Berry <[email protected]> wrote:
>
>> ?- string_lower("Foo", X), X = "foo".
>> false.
>>
>> ?- string_lower("Foo", X).
>> X = foo.
>>
>> ?- string_lower("Foo", "foo").
>> true.
>>
>>
>> Is there any particular reason for this? Isn't the point of strings to
>> avoid the overhead associated with atoms?
>>
>
> It looks like string_lower/2 is using a slightly more general definition of
> "string" which includes both string objects and atoms.  For example, you
> can also provide an atom as the first argument.
>
> Since we already have downcase_atom/2, I can't think of any reason why we'd
> want string_lower/2 to behave this way.

As all similar predicates, it deliberately does overloading on the inputs,
but outputs are supposed to be of the indicated type.  Fixed.

	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.