ietf-mta-filters
[Top] [All Lists]

Re: Integer variables

2003-04-19 07:44:46

[Alexey Melnikov]:

  Kjetil Torgrim Homme wrote:
  
  > the problem is rather that the variable can only be expanded
  > inside a string, so it would lose its integer property.
  
  Which is fine, as long as this is documented.  I believe the
  current document doesn't specify what types of variables are
  allowed.  You have to either explicitly allow or prohibit this.

it is explicit already, if you look in the right place:

|   Syntax:   set [MODIFIER] [COMPARATOR] <name: string> <value: string>
                                                          =============

it doesn't say anything about variable references being usable outside
of string interpretation, I guess that could be more explicit, but the
overall Sieve grammar doesn't allow an unadorned variable reference as
a syntactic element.

(if a numeric variable was to be introduced, it seems to me that to
access it, changing the allowed values for QUANTIFIER to include a
variable-ref would be the way to go, i.e. 1${count}, ref. 1M.)

  > do you have a use for integer variables?
  
  You already have the "length" function.

yes, it may be a bit silly.  a determined hacker can use it to convert
numbers in unary to decimal (I've had to do this during crash recovery
in singleuser mode on SunOS ;-), but the lack of a looping construct
will cramp his style.

  I was thinking something along the lines of comparing
  lengths/counting headers/scoring.  However this will probably
  require some actions for simple arithmetic (+/-).

with regex, you can do:

    set "score" "${score}1";  # several times inside if-blocks

    if string :regex "${score}" "1{5,}" {
        # five or more hits ...
    }

-- 
Kjetil T.

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