Forum OpenACS Development: Re: db_multirow and db_foreach -unclobber

Collapse
Posted by Robert Locke on
Looking at Tcl's foreach, if I do:
    set somevar old
    set somelist [list 1 2 3 new]
    foreach somevar $somelist {}

Then "somevar" will have a value of "new" (not "old") after the foreach has been executed.

I understand the motivation for Lars' change, but I find the current behavior more consistent with how I expect Tcl to work.

Perhaps add the noclobber option, but do not make it the default?  This also skirts the backward-compatibility issue.

Collapse
Posted by Vinod Kurup on
I think that db_foreach and db_multirow should have different behaviors. db_foreach should be an analog to TCL's foreach, so it should clobber vars in the local namespace. db_multirow is meant to create vars in a specific namespace (i.e. in an array which has the name of the first argument to db_multirow), so it should *not* clobber vars in the local namespace. IMHO, of course.