Subject: variables and side-effects of tests

From: Marc Mutz <[email-masked]>
Date: Sat, 10 May 2003 21:44:53 +0200

Hi!

From RFC3028:
2.5.     Tests

<snip>

   Tests MUST NOT have side effects.  That is, a test cannot affect the
   state of the filter or message.  No tests in this specification have
   side effects, and side effects are forbidden in extension tests as
   well.

   The rationale for this is that tests with side effects impair
   readability and maintainability and are difficult to represent in a
   graphic interface for generating scripts.  Side effects are confined
   to actions where they are clearer.

So the variables extension, as it stands, violates this MUST, since the 
numerical variables are set as a side-effect of a test with :matches 
match type. :-(

What now?

Marc

-- 
If you read this Mail while moving in traffic, you could hit
lantern stakes or end up knocked over by trucks.
                       -- freely adapted from iX 11/2002 editorial

---

From: [email-masked]
Date: Sat, 10 May 2003 15:31:00 -0700 (PDT)

> What now?

We have to reach consensus to revise the specification and remove the MUST. 

				Ned

---

From: Kjetil Torgrim Homme <[email-masked]>
Date: Sun, 11 May 2003 04:04:28 +0200

[Ned Freed]:
>
>   [Marc Mutz]:
>   > So the variables extension, as it stands, violates this MUST,
>   > since the numerical variables are set as a side-effect of a test
>   > with :matches match type. :-(
>   >
>   > What now?
>

I don't object to a revision of RFC 3028, but an alternative may be to
replace the numerical variables with

  SETMATCH <variables: string-list>

the :matches will change the internal state, and this is still
observable by a user, so it may not be good enough to satisfy language
lawyers.

Example:
  if address :all :matches "To" "*+*@*.ifi.uio.no" {
     setmatch [ "user", "", "host" ];
  }

(the empty string means throw the value away.)  at least it gets rid
of this problematic code:

  if header :matches "Subject" [ "make * fast", "free ${1}!" ] {
     ...
  }

the behaviour of the above code is an open issue.  I assumed "free
${1}!" would be interpolated _before_ the test was executed, but then
Jutta came up with replaceheader where an argument string is
interpolated _after_ the tests built in to the action have been
performed.  the variables draft does not contain any definitive
wording on this issue.

-- 
Kjetil T.

---

From: [email-masked]
Date: Sat, 10 May 2003 20:48:59 -0700 (PDT)

> observable by a user, so it may not be good enough to satisfy language

Well, previously there was no internal state that wasn't implicit in the
problem structure. Now there is, and the test changed it. I can live with
it, but others may feel differently...

>      setmatch [ "user", "", "host" ];

I actually sort of like this, but it isn't clear to me it really solves the
problem.

				Ned