[Top] [All Lists]

Re: Questions about the Require Command.

2000-12-12 14:58:03
2 Questions.


  2.10.5 Extensions and Optional Features


  If an extension is not enabled with "require", implementations MUST
  treat it as if they did not support it at all.

By this do we mean that if a script uses a fileinto action, but didn't
declare it with require, then we should produce an "unsupported extension"
error when we reach the fileinto token even if we support fileinto?

The important thing is that an error is produced. I don't think
it is critical that the specific error be "unsupported extension". After
all, we don't even have a precise error return model in this work.

i.e. take the following script.
  require "regex"

  if (header :regex "Cc"
      "Some regular expression or other") {
      fileinto "FolderName";

If we support both fileinto and regex are we meant to produce an error here? 

I believe you should produce an error in this case.

I could see how you could interpret section 2.10.5 this way but surely if we
are being conservative with what we produce, and liberal with what we receive
we should accept this script and accept the fileinto command?

IMO this isn't a good place to apply this principle.

Could someone clear this up for me?  I'd suggest a re-wording of the section
to make the intention clearer/more spelt out.

I have to say I see nothing unclear here. If you don't have a require clause
for a particular extension it isn't legal to use it. Requiring an unrelated
extension doesn't change this.

  3.2 Control Structure Require

  The require command, if present, MUST be used before anything other
  than a require can be used. An error occurs if a require appears
  after a command other than require.

Could we improve the wording here too?  It took me quite a while to get my
head round what you were getting at (even though I could have guessed).  I am
assuming that this means that you may only have comments, whitespace and
require commands before a require command.  It could read:

  Require commands, if present, MUST occur before all other types of command
in the script.  An error occurs if a require appears after a command other 

I have no problem with this.

So therefore this would be ok:

  /* This is the main require extension command that declares the extensions 
that we are about to use */
  require ["regex","fileinto"]

  # This is an auxilliary require command added by a user.
  require "x_some_other_extentsion"

  if (header :regex "Cc"
      "Some regular expression or other") {
      fileinto "FolderName";
but not
  require "regex"
  if (header :regex "Cc"
      "Some regular expression or other") {

  require "fileinto"

Yes, exactly.


<Prev in Thread] Current Thread [Next in Thread>