6

I have many packages some of which use some of others. I have many symbols defined in them. Is there a reliable way of finding declared/exported but undefined functions/symbols in several interrelated packages?

user13253
  • 8,666
  • 2
  • 42
  • 65

1 Answers1

4

So here is an answer to Rojo's interpretation (which I agree with) of that question:

Select[Names["Global`*"], (First[ToBoxes@Definition[#]] === "Null") &]

Replace "Global`" with context of interest.

Maybe doesn't look neat but works well so far. It is based on an assumption that Definition of a symbol without any values will return Interpretation[Null,Definition[...]]


Another method not based on boxes:

With[{
  info = {Attributes, DefaultValues, DownValues, FormatValues, 
    Messages, OwnValues, SubValues, UpValues, NValues}
  },
  Select[
     Names["Global`*"],
     {} === Flatten @ Through[
        info[ToExpression[#, StandardForm, Unevaluated]]
     ] &
  ]
]

or something less documented

Select[
  Names["Global`*"],
  {} === ToExpression[ #, StandardForm, 
     Echo @* Flatten @* Values @* Values @* First @* 
     Language`ExtendedFullDefinition 
  ] &
]

Both ideas stolen from Triggering actions when a variable is set

Kuba
  • 136,707
  • 13
  • 279
  • 740