Re: Why do we need #set $x = 1

"R. Tyler Ballance" <[email protected]>
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
On Sun, May 17, 2009 at 10:14:29PM -0700, [email protected] wrote:
>    Why do we need?
>    #set $x = 1
>    why not just
>     $x=1
>    Thanks


Because the former is far easier to parse :)

To properly "pick up" the latter, we would need to identify constructs
where the dollar sign was used and see if there was an assignment
occurring. Instead we use a 'raw' dollarsign to denote the invocation of
the NameMapper. Anywhere you use $foo, the NameMapper will be invoked to
look for a variable named 'foo' in your searchList(s).

The use of '#set' and other hash directives manipulations of Cheetah's
state, whereas '$' directives are purely read-only, output related
statements. This helps us keep a logical separation between the
"language" portion of Cheetah, and the "output generation".


The four extra characters are worth it IMHO ;)


Cheers
-- 
-R. Tyler Ballance
Slide, Inc.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkoQ78AACgkQFCbH3D9R4W86cACgo9uqehtzQKHiLb/ZCdRPf8Dt
EuwAmQHjoU02Mn/DVrFeuPeMQulsc5eW
=UBx6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.