[pmwiki-users] Pagelist definition problem (fixed?)

Patrick R. Michaud pmichaud at pobox.com
Fri Oct 6 14:01:01 CDT 2006


On Fri, Oct 06, 2006 at 10:35:19AM -0700, Martin Fick wrote:
> --- "Patrick R. Michaud" <pmichaud at pobox.com> wrote:
> 
> > Don't forget the "expr" conditional to (:if:) when
> > doing a multi-tested conditional such as this.
> 
> I forget, is the expr just an artifact of the original
> recipe or is it there to prevent breaking already
> existing pages that might have ands, ors... already in
> them that aren't supposed to be interpretted?

Neither.  The form of the (:if:) directive is always

    (:if cond args:)

where "cond" identifies the type of condition to be tested.
The (:if:) directive itself doesn't understand any form of
complex expressions, it's the "expr" condition (the first
parameter to "(:if:)") that does that, and the complex condition
is just the argument to "expr".

Moving the complex conditional into (:if:) (eliminating the "expr")
would mean changing the way that (:if:) is parsed and handles its 
conditions -- and that's not entirely trivial.  

Although, perhaps what we could do is to scan everything in the 
(:if:) directive for things that are indicative of a complex expression.
Then if we see any, we just assume that it's an "expr" condition and
call it that way (but let the "expr" routine handle any
actual parsing of arguments, as it does now).

Would that work?  That's also pretty nice because it means the
handling of the expression syntax in (:if:) remains pluggable.

This *could* cause a problem in the case where someone writes

    (:if equal {$:a} {$:b} :)

and either {$:a} or {$:b} contain simple words like "and", "or", "xor"
(or anything else that is an "operator" in our complex conditions).
If that happens, then the (:if:) directive and "expr" will end up 
mis-interpreting the "and" for being an "operator and" instead of an 
argument to "equal".  Granted, this sort of thing would be pretty rare, 
but I don't know if there are other similar cases I haven't thought of.

> I can't tell you how many times I have pulled out my hair
> debugging pagelist templates just to finally realize I
> forgot the expr!  I can't see that it would be intuitive 
> for newbies?

Yes, I totally understand -- I constantly see people putting
complex expressions in (:if:) and omitting the "expr", so it's
pretty clear that people don't think to include it.

Pm





More information about the pmwiki-users mailing list