Forum OpenACS Development: Re: passing arguments, ad_proc definitions

Collapse
Posted by Torben Brosten on
Apparently, this is something conceptual within my mind that I revisit now and then (and hopefully didn't post about before). It's the idea that a proc can have any number of ordered parameters. TCL doesn't have this at the procedure definition, but then what language does? (rectorial question)

Using standard proc format, the max number of parameters can be designated with empty string as a default.

Actually, this discussion has been fruitful.

Example:

ad_proc -public qf_test {
{named_param_1 ""}
{named_param_1_value ""}
{named_param_2 ""}
{named_param_2_value ""}
...
pattern continued to max number of parameters
} {

Thank you for the exercise, Dave.

cheers,

Torben

Collapse
Posted by Dave Bauer on
Hmmm. This makes me curious.

Are the parameters known at the time of procedure definition or are they unknown?

If you use the format like this:

ad_proc -public template::element { command form_id element_id args } {
Manage elements of form objects.
} {

This is called like so:

template::element create $form_id $element_id -label "Label" -widget "Widget" -html "html" etc...

You can have an arbitrary list of named parameters which will be in the "args" variable.

If you pass this list to get_opts it will parse them into an array. This seems like what you were asking for, but maybe I am confused.