[Top] [All Lists]

testing for extensions during run-time

2006-01-10 18:38:28

On Tue, 2006-01-10 at 19:06 -0500, Barry Leiba wrote:
I still wonder whether there ought to be a way to test for the presence
of an extension, rather than only to have the choice of *requiring* it
or not using it at all.  I can see a script wanting, for example, to
send a notification IF the Notify extension is available, but not
wanting the script to FAIL if it's not.

it certainly seems useful to me.  we could introduce an action, like:

  require "environment";
  # or perhaps a separate extension.
  want "notify";
  if environment "extensions" "notify" {

since the grammar of Sieve is regular, an unknown extension can't
introduce elements which changes syntax parsing.  furthermore, the
validity of the elements in the script can easily be verified during
upload: if you find an unknown keyword or element, you look upwards in
the blocks leading down to the statement.  if a block is conditional on
the existence of an extension, and the extension is unknown, ignore the
statement, otherwise flag the error and refuse the upload.  a
bytecompiler can omit the complete block in its representation.

an implementation which does no verification during upload is no worse
off with this mechanism than without.  random syntax or semantic errors
can appear anywhere and must be handled anyway.

an anyof test does throw a spanner in the works, though.  I think it is
appropriate to disallow this explictly (although a _bit_ ugly), and have
the validation during upload assume that an anyof which includes an
extension test is _always_ true, even when the extension is unsupported.
(this is still the code for the script verifier I'm talking about.)

actually, the "want" action may be superfluous, but I think it should be
used to keep dependencies explicit up front.

just some random thoughts,
Kjetil T.