Re: name:variable

Brandon Long <[email protected]>
Newsgroups gmane.text.clearsilver.general
Organization Fiction L Networks
Message-ID <20071129031855.GB29062@bl1>
On 11/28/07 Sovande Ulv uttered the following other thing:
> 
> On Nov 27, 2007, at 10:09 PM, Sovande Ulv wrote:
> 
> > I understand that '-' and '+' may be tricky in variable names, but
> > this could easily be handled by using the parse->hdf tree as a symbol
> > table and look up a variable there first.
> >
> Enclosed a patch which allows for using variable names with operator  
> tokens such as [?<>=!#-+|&]. The patch use parse->hdf as a symbol  
> table and first try to lookup a variable before parse, in  
> csparse.c:var_parse().
> 
> If one have a hdf tree such as this
> 
> > Request.Header.Host = localhost:8080
> > Request.Header.Connection = keep-alive
> > Request.Header.Accept-Encoding = gzip, deflate
> > Request.Header.Accept-Language = en-us
> > Request.Header.Accept = text/xml,application/xml,application/xhtml  
> > +xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> > Request.Header.Cache-Control = max-age=0
> 
> The patch will make statements such as <?cs var:Request.Header.Accept- 
> Encoding ?> work as expected and print "gzip, deflate" instead of 0.  
> There are no other expression side effects. The extra statement to  
> lookup a variable in var_parse() may even speed up things in those  
> cases where the var: statement is used with a var:variable which  
> probably are most cases.  Hope you will accept this patch Brandon.

Yeah, I don't think this is going to work.

For instance, this expression won't work:
<?cs var:url_escape(Request.Header.Accept-Encoding) ?>

Even if we did the lookup in parse_expr instead, you'd get confusing
results based on wether or not Request.Header.Accept-Encoding existed.

Plus, HDF variable name lookups aren't the fastest things.  Also, this
adds yet another place where vars have to exist at parse time.

And I just don't think its that hard to not have vars with +/- in them.

CGI just munges Accept-Encoding to Accept_Encoding, the C++ wrapper I
use at Google just munges it to AcceptEncoding, and I should probably
just add that code to the cgi wrapper in ClearSilver.

Also, I'm pretty sure this works if you have to have these types of var
names:

<?cs var:url_escape(Request.Header["Accept-Encoding"]) ?>

Brandon
-- 
   "Don't let anybody tell you what you should like and enjoy and 
    what you shouldn't like and enjoy.  Like what you like, enjoy what
    you enjoy, and don't take crap from anybody." -- RAW
                                           http://www.fiction.net/blong/
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.