Subject: regarding short-circuiting

From: Kjetil Torgrim Homme <[email-masked]>
Date: Thu, 12 Aug 2004 20:14:31 +0200

while perusing the list archive, I found another point which probably
needs addressing in the draft.  consider:

        if address :matches ["To", "Cc"] ["kjetilho@*", "k.t.homme@*"]

if a message contains both "To: [email-masked]" and "Cc:
[email-masked]" -- what's the value of ${1} ?

the current draft says:

        The interpreter MUST short-circuit tests, ie. not perform more
        tests than necessary to find the result.

so the behaviour is undefined.

one suggestion was to specify ordering explicitly:  for each pattern,
iterate over each header in the list.  (according to this algorithm,
${1} holds "darwin.uio.no".)

the other view is that users which need determinism can write

	if anyof(address :matches ["To", "Cc"] "kjetilho@*",
		 address :matches ["To", "Cc"] "k.t.homme@*")

in either case, I think the draft should make clear whether the result
is undefined or not.

on a slightly related note, the draft rules out cute tricks such as

	if allof(address :matches ["To", "Cc"] "kjetilho@*",
		 address :is ["To", "Cc"] "abuse@${1}")

based on this wording:

        The expanded string MUST use the variable values which are
        current when control reaches the statement the string is part
        of.

in other words, ${1} expands to the value it had before the first
address test.

(the user can get the desired behaviour by nesting if-tests.)
-- 
Kjetil T.

---

From: [email-masked]
Date: Thu, 12 Aug 2004 11:44:34 -0700 (PDT)

> so the behaviour is undefined.

I suggest that this case is best left undefined.

> in either case, I think the draft should make clear whether the result

I agree. I have no problem with requiring left to right short circuit
evaluation of anyof and allof since I suspect most implementations do it
this way already. Evaluating lists in order may be more problematic, and I
could easily see different implementations having done iterators over
multiple list arguments differently, and it is quite possible for
them to have good reasons for doing so.

> in other words, ${1} expands to the value it had before the first

This sort of thing can get to be so unclear I'm almost tempted to
leave it undefined as well so people won't write stuff this obscurely.
But that's probably a bad idea.

				Ned

---

From: Kjetil Torgrim Homme <[email-masked]>
Date: Thu, 12 Aug 2004 21:16:50 +0200

> I suggest that this case is best left undefined.

okay, I added two sentences to the paragraph:

        The interpreter MUST short-circuit tests, ie. not perform more
        tests than necessary to find the result.  Evaluation order MUST
        be left to right.  If a test has two or more list arguments, the
        implementation is free to choose which to iterate over first.

-- 
Kjetil T.