How to extract the names of functions from a Julia file?

Consider the following file fragment:

function plus(a, b)
    return a + b
minus(a, b) = a - b

I want to parse this file to extract the names of the functions. Thus in the example I wish to obtain the list [“plus”, “minus”]. How can this be done in the simplest manner?

Maybe not the simplest, but this works
Skip the following if that file already contains a module:

module dummy


syms = names( dummy, all = true )
filter( x->getproperty(dummy,x) isa Function, syms )
1 Like