[Email-SIG] invertability and idempotence

Stephen J. Turnbull stephen at xemacs.org
Thu Oct 22 20:09:43 CEST 2009


Andrew McNamara writes:

 > > > didn't want to introduce new terminology. But referring to this:
 > > > 
 > > > >    generate(parse(msg)) == msg
 > > > 
 > > > as "idempotency" is perfectly valid in my opinion (as in, applying an
 > > > operation multiple times produces the same result). 
 > >
 > >That would be generate(generate(msg)) == generate(msg) or
 > >parse(parse(email)) == parse(email).  The input and output of
 > >these functions are of *different types*, they cannot possibly be
 > >idempotent.
 > 
 > You're splitting hairs - the operation "generate(parse(X))" is
 > idempotent, and that's what I was referring to.

Yes and no.  The equation above does imply idempotency, but it is a
much stronger statement: generate(parse()) is the identity.  That
stronger statement could be useful in practice, but it could also be
expensive to implement.  That tension could engender flamewars if the
requirement is expressed by the word "idempotency" but the intent is
"identity".

For example, suppose that for MIME multipart messages, generate() uses
"$%$%$%$%$%$" as the separator as long as no component contains that
string.  Then generate(parse(msg)) will be *equivalent* but not
*identical* to msg for most messages received from non-Python-email-
using MUAs.  generate(parse()) is idempotent, though.  I don't think
the folks who ask for "idempotency" would be satisfied with that!

As I said earlier, if we're going to use the word "idempotent" to mean
"invertible", that's established practice, so we footnote the
Humpty-Dumpty-ism, and I can live with that.  But if we're going to
try to be more accurate, let's be fully accurate.


More information about the Email-SIG mailing list