What configuration one chooses depends on the specific needs of the function one is compiling and other general considerations about the relative place and function of that piece of code in the rest of one's script/program.
With that in mind, one way to achieve what is being asked is to use With; this way, one can incorporate simple constants in a compiled function, eg
(* a compiled function with a constant *)
f = With[{alpha=3.507},
Compile[{{x,_Real}}, 2*alpha-x*1.09]
]
The approach presented above addresses the need to use "constants* inside the compiled function; local variables that can take on different values during the lifespan of the local scope need to be introduced in a different way.
f = Compile[{{x,_Real}}, Module[{y=x+3.},
Log[y]
]]
This last example, contrived as it might be, introduces the use of local variables inside a compiled function with the help of Module.
The first answer to this question, has a lot of packed information on the use of Compile; there are also examples of uses with compilation that uses local variables.
Also, as a side-note, the first answer to this question demonstrates the various scoping structures available in Mathematica.
I include this last link, although it is not directly related to compilation, because the question involves the use of Block; I have refrained from using it in this answer, as the linked response suggests that it should be used in those cases it is absolutely necessasary to, otherwise Module will suffice.
BlockorModulein the body of the compiled function. It does not matter; both ways just tellCompileto make the variables local. $\endgroup$Associationsare not compilable. No, function pointers cannot be used as arguments of aCompiledFunction. Yes, I think recursive calls are possible (with some trick that you have to look up on this site), but I would really discourage to use them because -- IRCC -- they are realized byMainEvaluatewhich pretty much defeats the purpose ofCompile. $\endgroup$