[Email-SIG] invertability and idempotence

Stephen J. Turnbull stephen at xemacs.org
Thu Oct 22 10:00:13 CEST 2009


Andrew McNamara writes:

 > The discussion had referred to idempotency up until that point, and I
 > 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.

I'm +1 on changing to use "invertible", -0 on continuing to use
"idempotent" (since it's the traditional idiom), and -1 on using
"idempotent" to mean "is deterministic", ie, generate(msg) ==
generate(msg).

If msg changes state in an irrelevant way, it would be nice to produce
the same output from generate.  But that is not "idempotency".

And we would need to specify precisely what irrelevant means.  For
example, if a client of the Message class decides to specify the MIME
boundary explicitly, then the output of generate has to change IMO.
OTOH, many MIME implementations put the time of day or the generating
process into the MIME boundary.  This is unnecessary (boundaries need
to be unique only message-wide, and the email package can adjust the
boundary to not conflict with message content, eg, Emacs/Gnus uses
something like "-=-=-=-=-" by default), and I would hope that email
avoids such practices when possible.



More information about the Email-SIG mailing list