Replies: 2 comments 1 reply
-
That's kinda why DCG non-terminals kinda appear as if they were normal predicates with 2 extra arguments: the most straightforward implementation is using 2 extra arguments to thread the list differences. I've heard there's better ones performance-wise, but as far as I know every single Prolog system with support for DCGs does the implementation like this. |
Beta Was this translation helpful? Give feedback.
-
You are confounding an implementation with the abstraction provided. The meme is misleading: There is not one way to implement grammar rules. Also note that differences, when used directly, offer more flexibility (like, you may reorder goals), but at the price of not guaranteeing properties like steadfastness of the 3rd argument in From a programmer's perspective, the best is to not rely on this mapping at all. ph#1 shows a case where a normal built-in is called as a non-terminal. In order to ensure that such code runs, you need to ensure that the Prolog system guarantees such a translation. But this is not uniformly the case as ph#32 illustrates. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note: this is misleading, see explanation! Thanks @UWN!
This was a mind blowing realization while I was studying list differences today 😅
Power of Prolog:

Beta Was this translation helpful? Give feedback.
All reactions