documentation – What are the best practices and common pitfalls of using Compile?

As evidenced by my last question, there are many things I do not know about how to write compilable functions.

The basics are clear: you have to load the appropriate packages


and should check the availability of an appropriate compiler:


and it's helpful to remember the functions that can be used to avoid MainEvaluer (for which I did not register the source but I am now happy to credit this thread where also other useful information)

Compiler`CompilerFunctions[] // Trier
Internal`CompileValues[](* trigger 
automatic loading *) ClearAttributes[Internal`CompileValues, ReadProtected];
syms = DownValues[Internal`CompileValues] /.
     Verbatim[HoldPattern][Internal`CompileValues[sym_]]:> _]:> sym;

However, once everything is done, you must always remember that a compiled function definition expects its arguments to be of well-defined types – Integer, Real, Complex, and n-dimensional tensors. (matrices).

What is not clear, even after proofreading the documentation, is the proper specification and use of temporary variables. It seems, for example, that these too must be of simple types and that the compiler does not automatically constrain them to compatible types. Then there is also the question of using eg GetElement has even thought that Part is a compilable function, and why Do is perhaps better than Table.

Where can this additional information be found and what orientations would the community offer for the rewrite functions for compilation?