[Zope3-dev] Re: Number of languages in Zope 3

Jim Penny jpenny@universal-fasteners.com
Wed, 9 Apr 2003 17:28:05 -0400


On Wed, Apr 09, 2003 at 03:34:10PM -0500, Evan Simpson wrote:
> Jim Penny wrote:
> >I started out hating ZPT.
> 
> By this I take it that you have been won over, to some extent.
> Nonetheless, I'd like to address your issues, since they *were*
> considered in detail during the design of TAL, and even documented.
> 
> >there were a lot of precedence rules with no clear explanation of of
> > why they were there.
> 
> I quote from TAL spec v1.4:
> 
> '''The reasoning behind this ordering goes like this: You often want to
> set up variables for use in other statements, so define comes first. The
> very next thing to do is decide whether this element will be included at
> all, so condition is next; since the condition may depend on variables
> you just set, it comes after define. It is valuable be able to replace
> various parts of an element with different values on each iteration of a
> repeat, so repeat is next. It makes no sense to replace attributes and
> then throw them away, so attributes is last. The remaining statements
> clash, because they each replace or edit the statement element.'''

No.  This is not the policy, not the reason.  The reason is that ZPT is 
based on XML and XML attributes may be arbitrarily re-ordered by parsers.  
That is, the reason you have all those levels of precedence is because 
XML forced it; not because the ZPT designers thought it was a good idea!
The quoted paragraph is horrible, because it details completely what was 
done with no idea of why anyone would even consider doing such an 
apparently daft thing.  Note the talk-back of 2.6 has the same objection 
in it.  (Posted by someone else.)

> 
> >Some keywords are verbs; some are nouns.  All but one of the keywords
> > are singular; but suddenly attributes is in plural.
> 
> The verb/noun mix is an unfortunate result of compromising between a
> desire for imperative tone and for keeping verbosity (a little) under
> control.  The uncompromising tone version would have been something
> like: 'define-variables', 'conditionally-retain-element', 
> 'repeat-element', 'replace-element', 'replace-element-content', 
> 'replace-attributes', 'conditionally-omit-tag', and 
> 'on-error-replace-element'.  Yech.

Actually content and contents are pretty interchangable (in ordinary
English), and attributes is probably most frequently used with a single
attribute.  It would be awfully nice if content and contents; and
attribute and attributes were alternative spellings of the same thing.
I cannot begin to count the number of times I have spelled
tal:attribute="href ...", because my mind knows there is only one
attribute to follow.

> 
> The singular/plural mix is simpler -- only 'define' and 'attributes'
> have (potentially) more than one clause, and 'define' already works well
> with any number of clauses, by virtue of being a verb :-)
> 
> >There is the gratuitous renaming of 'container' to 'here'.

Yep, my bad.

> 
> Not gratuitous, and not 'container'.  We used 'here' instead of 
> 'context', because 'context' is awfully generic, and we were referring 
> to the *entire collection* of 'container', 'here', 'root', 'user', etc. 
> objects as "contexts" (see the builtin TALES name 'CONTEXTS'!). 
> Frankly, I wish 'here' replaced 'context' in Scripts as well.  It's a 
> nice name, implying placefullness, which is the whole raisin d'eater of 
> that "context".
> 

So how about allowing both here and context in both ZPT and
pythonscripts?  I don't really care too much, but I am thinking
pedagogically.  I am trying to teach some people Zope here.  That
the name of "the current folderish object" changes in python expressions
depending on whether I am in a ZPT or a Script feels pretty wrong.  (And
it changes again External Methods, but that is less of a problem; as
that is by long-standing python convention, and I am not worried about
External methods for these people.  EM's are among the last tools most
Zopers need.)

In other words, if we are to encourage people to use ZPT for
presentation and Script Pythons for logic, there needs to be as little
impedence mismatch as possible.  The use of "here" in one language and
"context" in another for the same thing, when writing snippets of python
and when you are expected to switch back and forth fluidly is simply an
unneeded mental mismatch.  To have been wrong consistently, or to enter
an interim period when both are acceptable would be preferable to the
current situation.

> >But, if 'explicit is better than implicit', you have to show the 
> >parameters at call time.  Path expressions simply offer no support!
> 
> Yep.  This is a definite stumbling block.  At some point we may try to 
> backfill with some kind of argument sytax, but that's a slope (from 
> simple variable arguments, to paths, to general expressions as 
> arguments) that makes a lot of people nervous.

Yep.  That road leads to re-inventing python, probably badly (with 
/'s and .'s mingled madly, etc.  Hmm, that sounds like another poster).  
And this is one reason that I question the jihad to avoid python in ZPT 
at all costs.  I actually wish it were a bit easier to write python 
expressions, but can certainly live with "python: is explicit".

Jim Penny

> 
> Cheers,
> 
> Evan @ 4-am
>