[ZPT] Truncating strings

Shane Hathaway shane at zope.com
Thu Oct 23 07:39:40 EDT 2003


On Wed, 22 Oct 2003, Ian Bicking wrote:

> > 3. There is no precedent for the idea that ":" means you should call
> > something.  There is a precedent, however, for the idea that ":" means 
> > you
> > should switch to a different namespace (XML).
> 
> There's maybe a slight precedence in Smalltalk.  I don't care much 
> about the way the expression is formatted -- heck, even parenthesis 
> would work.  Namespaces, especially the way you propose, are hard and 
> require lots of backtracking.  Calling is easy.

I disagree.  Namespaces are easy.  So is a registry.  Namespaces are nice
because they don't get mixed up with the local variable namespace.

> > 4. You'd be better off writing your expression in plain old Python.  
> > More
> > explicit and no new syntax.  But again, the thing you've lost is that 
> > you
> > have to import something first, and that's a costly thing to do in a
> > template.
> 
> The problem with a Python expression is that the translation isn't so 
> good.  The expression will probably start out as something simple, like 
> "options/var/subvar", and only later do you want to format that.  It's 
> annoying to translate options/var/subvar to options['var].subvar, and 
> this way you avoid that.

Your syntax has the same problem.  Your syntax looks likes it's begging to 
be Python, so just write it Python. :-)

Your real contention, I believe, is over the ":" character.  You're 
parsing the colons before the slashes.  It is intended that you parse the 
slashes before the colons.  What if I wrote it this way instead:

  here/foo/fmt.strip()/fmt.truncate(10)

Then what would you think? :-)

Shane



More information about the ZPT mailing list