0
$\begingroup$

My version is 13.2. When debugging I came across this peculiar feature of Names.

Starting with a fresh kernel, define enter image description here

Then Names[{"context`*"}] will search all subcontexts while Names["context`*"] only search the first level, and the former causes unnecessary slow-down (according to the purpose). enter image description here

In my experience, the later behaviour is the common one for other symbols, e.g. enter image description here

Is this documented somewhere? (I read the documentation of Names but didn't find.) Are there any other symbols sharing similar behaviours with Names?

$\endgroup$
3
  • $\begingroup$ Names docs say, in details & options, that "Names["context`*"] lists all symbols in the specified context", so it is a special case. $\endgroup$
    – Kuba
    Commented Feb 8, 2023 at 15:03
  • $\begingroup$ @Kuba My question is that Names[{ctx`*}] will search all subcontext under ctx` . I didn't find any explanation in the doc. $\endgroup$
    – Lacia
    Commented Jan 31 at 11:05
  • $\begingroup$ Names[{f`*}] searches all names that match this. There is no such thing as a subcontext, f`x`x is just a symbol x in a context f`x` . Names[f`*] would return the same but they made a special case, and documented it, that it will look in f` only, so no f`x` etc. $\endgroup$
    – Kuba
    Commented Jan 31 at 11:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.