[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: inline mata vs mo/mlib?
Kit Baum <firstname.lastname@example.org> asked,
> [...] Say that you
> have an ado-file that calls one (or several) of your own mata
> functions. You could place those functions in-line in the ado-file,
> or you could compile them into .mo and put them into an .mlib.
> is there any real downside to distributing a single ado-file
> containing the mata functions inline versus distributing the .ado
> and .mlib (and presumably the .mata if you want to expose the code)?
> The inline code will be compiled when loaded, but once per session.
I recently wrote an ado file for which the ado part was 17 lines and
the Mata part 491. I recommend the all-ado construction if
1. there is not too much Mata code (say more than 2,000 lines),
2. you are willing to make public the Mata part, and
3. The Mata routines are not general-purpose functions that
you will want to call from other ado-files.
Concerning (1), remember compiles occur only when the ado-file is loaded.
Concerning the 2,000-line guideline, I should mention that lots of short
functions compile very quickly, whereas one 2,000-line function takes
longer. The compile time for a single function increases quadratically with
the number of lines in the function.
* For searches and help try: