The main drawback is that the usage of !/0 restricts the generality of this code: We cannot use this grammar to generate all strings it describes.
On the other hand, if we leave everything as is, and only remove the occurrences of !/0, we suffer a performance drawback, because parsing will create and leave choice-points and therefore become less efficient.
One solution for this is to rewrite the code as follows:
I noticed the following snippet:
The main drawback is that the usage of
!/0
restricts the generality of this code: We cannot use this grammar to generate all strings it describes.On the other hand, if we leave everything as is, and only remove the occurrences of
!/0
, we suffer a performance drawback, because parsing will create and leave choice-points and therefore become less efficient.One solution for this is to rewrite the code as follows:
This extends the fragment's generality when generating strings, and benefits from first argument indexing to retain its efficiency when parsing.
Note that no single quotes are needed when writing the atoms
*
and+
.