[Zope-dev] local/set

Phillip J. Eby pje@telecommunity.com
Fri, 10 Dec 1999 16:26:48 -0500


At 03:16 PM 12/10/99 -0600, Evan Simpson wrote:
>
>If only lexically enclosed code is allowed to alter Let variables, why even
>bother with non-writable variables?  Allow Set to operate on the enclosing
Let
>namespace, without limit.  Heck, allow it to introduce new names, if it
wants to.
>
>Thus:
>
><dtml-let x="1+1" firstname=" 'fred' ">
>  ...
>  <dtml-set firstname=" 'mary' " weight="135">
>  ...
>  <dtml-set qty="5" price="1.50" extprice="qty * price">
>  ...
></dtml-let>
>
>Note that this makes nested Let superfluous, and <dtml-let ...> is
essentially
>shorthand for <dtml-let><dtml-set ...>
>
>Now if every DTML object had a default empty local namespace, we could do
away
>with Let entirely and just use Set.

Um.  Couple of problems.  First, the DTML implementation architecture
doesn't really have an accessible notion of lexical scoping that can be
used to determine this.  Second, adding an extra namespace to every
DocumentTemplate would be create a potentially high performance hit
(because of all the alloc/free overhead being added to inner loops).

However, if there was a way to fix both of the above, your proposal might
work.  I would vote to keep let, however, so that you have a way to get rid
of variables you don't need.


>This diverges here, since 'weight' is *only* an attribute of 'person', not
a full
>member of the namespace.  Of course, to complete the insanity of my new
proposal,
>we could keep the colon notation as a compact way of defining/altering
this sort
>of sub-namespace 8->

Ugh.