Valerio Gionco <[EMAIL PROTECTED]> writes:

> Wojciech Kocjan wrote:


> > vars get -default "novalue" xyz

Sounds good.

> > $VARS should be used where you access many variables - hashing
> > should be faster than browsing apreq... While if you only access 5
> > out of 20 variables (and access the rest only in 1/50 cases :-),
> > vars should be faster...

> mod_dtcl must parse QUERY_STRING to find the right variable; every
> time you call [vars get xxx], the module (in the worst case) must
> parse every variable in the string - which is exactly what you
> wanted to avoid.

Well, in reality we could parse it up and store it internally so that
it is quick to return.

> > I also came up with another solution - if QUERY_STRING is
> > 'x=a&x=b&x=c' then $VARS(x) would be either one of them, but ONLY
> > when >1 value exists, then VARSL (or LVARS - sounds better :-) is
> > set. This way you avoid duplicate values.

> > But I'm not sure if it's so easy to check if an entry in apreq is the only
> > entry with such name...

> Too complex, I think. The result could be even slower than
> duplicating values (a lot of tests involved, both in mod_dtcl and in
> the scripts).

Isn't this more or less what you suggested?

     - ::request::VARS(x) returns a list with sub-lists:
             {this is comment 1} {this is comment 2} {this is comment 3}

     - a new variable ::request::VARSLISTS is added, containing a list
        of variable names that were assigned to more than one value. If
        your script knows that $x could be a list, it can simply look for
        'x' in $::request::VARSLISTS.

Here's a twisted way of doing things:

char *arr[] = {
    "a",
    "b",
    "c"
};
int arridx = 0;
int arrlen = 3;

char *traceproc(ClientData clientData,
                Tcl_Interp *interp,
                char *name1,
                char *name2,
                int flags)
{
    Tcl_SetVar(interp, "rotvar", arr[arridx], 0);
    arridx ++;
    if (arridx >= arrlen)
        arridx = 0;

    return NULL;
}

...

    Tcl_TraceVar(interp, "rotvar", TCL_TRACE_READS, traceproc, NULL);

;-)

Hrm... I keep thinking there must be a sneaky way to do it 'right'
without requiring a lot of checks.  PHP bails out by requiring that
you know ahead of time that certain things will have multiple values:
names have to be like so: <input type=checkbox name="foo[]" ....>.
Maybe it's just not possible.

-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to