Re: more version 7 woes re phrase/3
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 21/12/2013, at 11:01 PM, Jan Wielemaker wrote:
> This was added (as you may have guessed) to trap strings that are passed
> to phrase/3.
We've already seen that this could be better handled by a static
tool; breaking working code seems a high price to pay.
> Nothing changed to the compilation though. My first impression is that
> phrase/3 is designed to deal with lists.
phrase/3 is designed to work with whatever it is that the
DCG rules it calls happen to work with. Fair to say, however,
that the Quintus documentation explicitly called the second
argument "List".
> What about inventing another name for phrase/3,
Would it not have been much more useful to define
phrase(NT, S0, S) :-
( string(S0) ->
string_codes(S0, C0),
old_phrase(NT, C0, C),
string_codes(S, C)
; old_phrase(NT, S0, S)
).
What would be even better would be if the DCG translation
did something like
[X],S0,S =>
( S0 = String+I0,
S = String+I ->
succ(I0, I),
string_char(I, String, X)
; S0 = [X|S]
)
so that DCGs just worked with strings.
> or even, simply go back to the basics and rely
> on call/3:
>
> call(ruleset, StateIn, StateOut).
which does not transform the rule body correctly.