Drew Raines <[EMAIL PROTECTED]> writes:

> Those lines often turn into multiple-line, tagged, -argument
> monstrosities, though.  This isn't much more confusing even though
> you've added a bunch of parens and commas:
> 
>    if recipient == '[EMAIL PROTECTED]':
>       TMDA.tag({'from: '[EMAIL PROTECTED]',
>                 'reply-to': ['dated', '1w']})

Here's the beginning of the problem, though.  Because of namespaces,
which are a wonderful and powerful organizational mechanism in a
programming language, the above would actually be something like this:

from TMDA import Message
from TMDA import Action

if Message.recipient == '[EMAIL PROTECTED]':
    Action.tag(from='[EMAIL PROTECTED]',
               reply-to='dated=1w')

I simplified the call a little to make it look more like what people
are used to today.  Action.tag would be a Python function that takes
arbitrary keyword args, like this.

def tag(**kwargs):
    for header, action in kwargs.items():
        ...

Importing a filter into an already existing namespace is possible, I
think, though I'm not sure that Guido guarantees the current
implementation for future versions.  I think it requires using the
implementation function __import__ or something similar.  And even
then, what if the user wants to import a secondary filter; the
equivalent of 'include' today?  Do they have to write out the several
rather strange Python lines to import that code into the current
namespace also?

To keep it simple, every TMDA variable, rule type and action will have
to be in some namespace or another and accessed through those
namespaces, something like TMDA.Message.<header fields>,
TMDA.Rule.<rule functions> and TMDA.Action.<action functions>, where
TMDA is the package that already contains Util, FilterParser, etc.

I'm just not convinced yet that this is any easier than the filter
language as it exists today.  Although I readily admit that the basic
idea of writing the filter in Python is seductive.

> The benefit of having the power of a full language at your disposal
> dwarfs the minor inconvenience of typing a few punctuations marks.
> 
>    if sender == '[EMAIL PROTECTED]':
>       myfunc(Drew.BOUNCE, Drew.BOUNCE_MESS)
>       myfunc(Drew.FORWARD, '[EMAIL PROTECTED]')
> 
> Although, after writing it out, the API implementation would
> probably be just as bloated as the filtering language.

Or more.... :(


Tim
_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to