Re: Problem with phrase/3: help examples not working

Carlo Capelli <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABty9wyqgHkt7tzsBMtnTjp4vZHgoZ=0dYHNuS5MKeRJWi+Jow@mail.gmail.com>
2014-02-12 19:05 GMT+01:00 Francisco José Gallego Durán <
[email protected]>:

> Thanks for your reply, Carlo :). That works fine on version 6.6.0, but it
> also fails on 6.2.6 as there is no string_codes/2.
>
Would it be a good idea to add a version number to predicates in help
> files, to know the version when they were implemented?
>

> In which way have double-quoted literals changed in version 7.x?
>
>
Double quoted strings are no longer (by default) lists of codes. Jan
changed the representation to a more efficient one.
The change has been discussed in depth previously on this list, but you can
refer to documentation about
extensions<http://www.swi-prolog.org/pldoc/man?section=extensions>for
a survey.
I keep my SWI-Prolog updated building from source, then I have no opinion
about versioning...

bye Carlo

Cheers,
> Fran.
>
>
> ----------------------------------------------------------------------------------------
> *Francisco José Gallego Durán*
> Dpto. de Ciencia de la Computación e Inteligencia Artificial // Universidad
> de Alicante
> (+34) 965903400 (Ext. 2073)
>
> ----------------------------------------------------------------------------------------
>
>
> 2014-02-12 13:04 GMT+01:00 Carlo Capelli <[email protected]>:
>
> Hi Fran
>>
>> integer//1 is defined in library(dcg/basics) and double quoted literals
>> have changed a lot in latest versions (7.x).
>>
>> ?- use_module(library(dcg/basics)).
>> %   library(pairs) compiled into pairs 0.00 sec, 22 clauses
>> %  library(lists) compiled into lists 0.02 sec, 122 clauses
>> % library(dcg/basics) compiled into dcg_basics 0.03 sec, 201 clauses
>> true.
>>
>> ?- string_codes("123 ready", Cs),phrase(integer(N),Cs,P).
>> Cs = [49, 50, 51, 32, 114, 101, 97, 100, 121],
>> N = 123,
>> P = [32, 114, 101, 97, 100, 121].
>>
>>
>> 2014-02-12 12:50 GMT+01:00 Francisco José Gallego Durán <
>> [email protected]>:
>>
>>> Hi everyone,
>>>
>>>    I am pretty new to this list, but I have been playing with prolog for
>>> several years and using Swi-Prolog quite a lot. (I implemented a game
>>> called PLMan<
>>> http://plman.i3a.ua.es/downloads/category/1-game?download=1%3Aplman>that
>>>
>>> we use to teach logic and prolog programming to our students at the
>>> University of Alicante).
>>>
>>>    I have a machine with Arch Linux and SWI 6.2.6 32bits multithreaded,
>>> and
>>> looked at help(phrase) to find this example:
>>>
>>> *    | ?- phrase(integer(X), "42 times", Rest).
>>>   |*
>>> *    | X = 42
>>>   |*
>>> *    ||Rest_=_[32,_116,_105,_109,_101,_115]____*
>>>
>>>
>>>
>>>    I copied it down to the interpreter and got this answer:
>>>
>>> *?- phrase(integer(X), "42 times", Rest).*
>>> *ERROR: phrase/3: Undefined procedure: integer/3*
>>> *ERROR:   However, there are definitions for:*
>>> *ERROR:         integer/1*
>>> *   Exception: (7) integer(_G550, [52, 50, 32, 116, 105, 109, 101, 115],
>>> _G578) ? *
>>>
>>>
>>>
>>>    Did I do something wrong, or is it just an outdated-help case?
>>>
>>>    I take this opportunity to thank Jan for his work in creating and
>>> maintaining SWI-Prolog. We have been using it for years and it has worked
>>> flawlessly :).
>>>
>>> Cheers,
>>> Fran.
>>>
>>>
>>> ----------------------------------------------------------------------------------------
>>> *Francisco José Gallego Durán*
>>>
>>> Dpto. de Ciencia de la Computación e Inteligencia Artificial //
>>> Universidad
>>> de Alicante
>>> (+34) 965903400 (Ext. 2073)
>>>
>>> ----------------------------------------------------------------------------------------
>>> -------------- next part --------------
>>> HTML attachment scrubbed and removed
>>> _______________________________________________
>>> SWI-Prolog mailing list
>>> [email protected]
>>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>>
>>
>>
>
-------------- next part --------------
HTML attachment scrubbed and removed
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.