Ned Freed wrote:
Given the fact that most extensions
introduce new language elements, the compiler must have some means of
ignoring/discarding the regions of the script that need the obscure
extensions.
Not necessarily. Additional tests, actions, arguments, and so on can be
added
bu the grammar never changes. So you can always parse the script and, in
the
case of an unknown element, simply compile it into something that
signals an
error if the execution path ever gets to that point.
Alternatively, doing the actual ihave test at runtime
requires that the compiler can distinguish between erroneous language
features and features that would have been introduced by the unknown
extension (in order to produce compile time errors or runtime errors
respectively). This would require knowledge about that obscure extension.
No, such knowledge is not required. See above.
Ok, first of all, I must agree with the statements you make that ihave
as a test command is cleaner in many ways. I also agree that doing the
ihave checks on unknown language elements (mostly) at runtime seems to
be a viable solution. I have one final remark/concern on this solution
however. Consider the following script:
require "ihave";
require "fileinto";
if ihave "frop" {
friep "This is a nifty feature.";
}
if header "X-Important" "yes" {
filinto "Important";
}
Now assume that this script is uploaded through ManageSieve. As you
know, ManageSieve compiles the script during upload to prevent the user
from installing a broken script. From what I understand from your
explanation, the obvious typo 'filinto' will not be noticed during
compile (because it may be part of the obscure "frop" extension that
could be enabled by ihave throughout the rest of the script) and the
ManageSieve upload will succeed. During runtime however, the script will
intermittently fail when the header test is true. Is there a way to get
around this issue?
Anyways, I think I should first give implementing this extension a try
before posting more concerns. I may be a bit biased towards finding more
difficulties if I have never actually tried to implement it. I'll keep
you posted when I do.
Regards,
Stephan