[ZPT] Re: TAL's lack of an else...
Chris Withers
chrisw at nipltd.com
Thu Aug 7 13:37:06 EDT 2003
Fergal Daly wrote:
> That's fair enough but I don't consider these to be programming except in the
> most general sense, TAL is not capable of simulating a Turing machine. I
> meant that general programming in XML is not progress, it's far too verbose
> for human comfort.
This is a good point. TAL is NOT a programming language. It's templating
language, and thw two are very different ;-)
> This is where we differ. I don't find it satisfactory, anything that makes me
> type the same thing twice, I consider bad and in need of elimination if
> possible. Having to type the same thing twice leads to errors. Repetition is
> what computers are good at and what humans are bad at.
The method I use involves no repetition, bar one variable name...
> This is what puzzles me (and it's not just you by the way) in one paragraph
> people say "you don't need else for generating XML" but then in another
> paragraph they say "even though I _never_ need it, I just use tal:define and
> and not:". People seem to have very fixed ideas about how to do something
> that never needs to be done ;-)
I know it may seem that way, but what I mean is that you don't need an else,
because what is already there suffices and provides more flexibility for less
syntax. It also makes TAL look less like a programming language and so
discourages them from entering into the real pain and suffering of trying to do
programming in a presentation language.
> Actually, TALES has a form of if/elif/else using the "|" syntax and it's
> widely used, so if anyone believes that if/elif/else is an advanced
> programming concept that has no place in a template language, they should
> rewrite any templates that use alternation in their expressions.
That's in TALES, where it's appropriate and has a very graceful syntax. Not
one's managed to fidn a graceful syntax for TAL yet, and until then adding stuff
is a hinderance rather than an aid.
>>No, it just makes the code cleaner, you get the same in python...
>>
>>average = (x+y+z)/3
>>if average <= 0:
>> print "eep!"
>>elif average > 0:
>> print "yay!"
>
>
> Except you forgot the case where average == 0. Assuming you do want to react
> to that, you need to add
Example corrected above.
> 1 would a if/else be useful in TAL? I think so and judging by some of the code
> I've seen people are doing it anyway, so I can't understand what the
> objection in principle is and as I pointed out TALES has a specific form of
> if/elif/else using the "|" syntax, so it is clearly a useful concept even in
> a template language.
If you can find a syntax which everyone likes and is _really_ _really_ simple
and can't be abused to start writing programming logic in TAL, then maybe ;-)
> 2 is it possible to do it nicely in TAL? This is the question I'd really like
> to have answered. As I've said before, none of the suggestions have been very
> nice. Does that mean there isn't a nice way?
>
> Unfortunately most of the debate has been about Q1
Well, that debate has been centered around your second question. There doesn't
seem to be a 'nice' way to do this in an XML-centric templating language. That
given, the consensus seems to be to stick with simplicity of syntax. I'm all for
that...
cheers,
Chris
More information about the ZPT
mailing list