I was wondering if there is a way to extract a procedure from another script without sourcing all of it. The goal in this case is to not create a new file with the methods separated from the main script file, but to use the procs that are into that script.
I have use open, read and source and eval.
The implementation of
sourceis almost exactly likeopen+read+eval(except with the C API). It isn't smart.In general, getting the contents of a procedure can only be done by using
info bodyafter it has been created (plusinfo argsandinfo default). But often people write code such that the wordprocis in the first column of a line and the body is all indented, with first following non-indented line being the closing}. That won't work in all cases (the main trickiness is whennamespace evalis in use) but will in many. Even then, the wordprocis probably the first on its line (with indenting) and the close-brace is aligned with it.I'm one of the few people that really writes code that doesn't always follow this convention. You don't need to worry about me.