# Compile without hardcoding

My question is how to pre-compile the rules1, rules2 and result parts of the following Module code without hard-coding the many (and changing number of) variables and rather complicated equations:

    fn[pars_]:=Module[{rules1,rules2,rules3,result},
rules1=[externalvars1->pars];
rules2=Join[rules1, externalrules/.rules1];
rules3=Join[rules2, externalfunction[externalvars2/.rules2]];
result=externalvars3/.rules3]


Thanks. (PS I have studied Mathematica's Compile tutorial and Rob Knapp's 2011 Presentation)

-
You will need to supply all relevant definitions, including the rules. At the moment, your question is unclear. –  Yves Klett Jul 9 '14 at 6:27
Dispatch[rules] might be what you are looking for. –  Stephen Luttrell Jul 9 '14 at 10:28
Thanks Yves and Stephen, I will investigate further –  stuartn Jul 11 '14 at 3:39