Tags:
create new tag
view all tags
At the moment composing an IF statement can be a bit of a nightmare, because it's hard to get the syntax exactly right with all these %'s flying around. Also, inside-out evaluation means that stuff inside the then and else clauses is always unconditionally expanded, pointlessly knackering performance.

Much as I dislike the standard escapes, it would be better - and more consistent - if %IF supported them in the then and else clauses, thus:

%IF{"condition" then="$percntTHEN$percnt" else="$percntELSE$percnt"}%

There is some risk that the expansion of standard escapes fouls up some pre-existing IF statement; but personally I think the risk is low, and outweighed by the utility of this proposal.

Using this feature - which I have already implemented - I was able to implement an optional pick-list for the topic parent in the WebTopicCreator, without complex calls back to the server, significantly improving performance of topic creation in large webs.

I'd like to hear any voices of dissent ASAP, as I have this ready to check in, and it would significantly improve the usefullnes of %IF.

-- Contributors: CrawfordCurrie - 26 May 2007

Discussion

I think this is a very good and simple enhancement which also can have a positive impact on performance since the twiki vars inside the IF are not unconditionally expanded. And I so not see a huge risk on compatibility.

-- KennethLavrsen - 26 May 2007

I cannot disagree. But additionally, I find the most problematic with IF is the handling of quotes. As soon as the contents contains a quote character the construct falls apart.

-- ArthurClemens - 26 May 2007

Quote can be escaped by \" or by $quot. \" has worked for quite some time, AFAIK.

CC

Of course, but if you write then="%ICON{warning}" you will get a surprise outcome. Sometimes it works to use single quotes, but then the contents must not contain any single quote.

-- ArthurClemens - 26 May 2007

Ah, the escapes are a solution for this problem. I just noticed with WebTopicCreator I can write

then="$percntINCLUDE{$quot$percntWEB$percnt.$percntTOPIC$percnt$quot section=$quotallownonwikiword$quot}$percnt"

Now we only need a escape generator (form).

-- ArthurClemens - 27 May 2007

I will stick my throat out and claim that we have a quick consensus decision here. I want this close since we have a feature freeze and I do not want to send the signal that this proposal is committed after the feature freeze (SVN 13884).

-- KennethLavrsen - 28 May 2007

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2007-05-28 - KennethLavrsen
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.