I want to call a procedure passing variable data and store the result in a new variable. I tried a number of things. Some worked, some didn’t. Here are my findings:
- 
We cannot call the transclusion widget inside a
<$let>call:<!-- does NOT work --> <$let result = <$transclude $variable="myproc" param1=<<var1>> param2=<<var2>> /> > <<result>> </$let>It seems (unsurprisingly) that the
/>for the<$transcludeends the<$let>abruptly. - 
We cannot pass parameters to the procedure as filter parameters:
<!-- does NOT work --> <$let result = {{{ [<myproc><var1>,<var2>] }}} > <<result>> </$let>Procedure Calls does say
Procedure calls can be used in filters. The text is not wikified which again means that the parameters will be ignored.
so I guess this makes sense, although I don’t really understand it what wikification has to do with it.
 - 
But we can set the parameters in an outer environment
<!-- DOES work --> <$let param1 = <<var1>> param2 = <<var2>> result = {{{ [<myproc>] }}} > <<result>> </$let>where
param1andparam2are the names of the parameters tomyproc. - 
But there is a subtlety. Default parameters are not defaulted. You need to supply values explicitly:
\procedure myproc(param1, param2, param3:"XYZ: ") \whitespace trim <$text text={{{ [<param1>add<param2>addprefix<param3>] }}} /> \end <!-- DOES work, the default prefix, `param3` is supplied: --> ''test1'': "<<myproc 10 32>>" <!-- does NOT work: default parameter not defaulted --> <!-- Yes, I know it's silly to set var1/2 and then use them only to set param1/2. --> <!-- Imagine that var1/2 are set in some enclosing scope --> <$let var1 = 10 var2 = 32 param1 = <<var1>> param2 = <<var2>> result = {{{ [<myproc>] }}} > ''test2'': "<<result>>" </$let> <!-- DOES work - but only because we supply a value for what should have been defaulted --> <$let var1 = 10 var2 = 32 param1 = <<var1>> param2 = <<var2>> param3 = "PDQ: " result = {{{ [<myproc>] }}} > ''test3'': "<<result>>" </$let>yields
test1: “XYZ: 42”
test2: “42”
test3: "PDQ: 42"0Note that
param3is not defaulted or overridden intest2. 
Are there other techniques that work for this, especially any that allow default parameters to work properly?
