Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Removing the Context

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35771] Re: [mg35667] Removing the Context
  • From: Omega Consulting <omega_consulting at yahoo.com>
  • Date: Tue, 30 Jul 2002 07:22:25 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

At 03:45 AM 7/25/2002, Johannes Ludsteck wrote:
>Dear MathGroup Members,
>Tracing functions from Packages generates very long
>and confusing output, since long context names are
>printed. To give a short example, consider the following
>command sequence:
>
>DiscreteMath`Tree`
>
>t=MakeTree[Range[5]]
>
>Trace[TreeFind[t,3]]
>
>generates very long output. A simple strategy to strip
>it would be to use Trace[command, form] which only reports
>expressions matching form.
>But this does not alleviate the problem that package
>variable names are very long, since all package symbols
>have a long context. For example
>the private package variables 'm' and 'found' are printed as
>
>DiscreteMath`Tree`Private`m      and
>DiscreteMath`Tree`Private`found
>
>This makes Trace output almost unreadable.
>
>Can anyone suggest a simple idea how to remove the long
>context names in Trace output?
>
>I defined a function which cuts the context from
>symbols, but this seems awkward an application of
>the function to the output is not trivial.
>
>Best regards,
>         Johannes Ludsteck

Which symbols are available via short names is controlled by $ContextPath.

If you reset $ContextPath to include DiscreteMath`Tree`Private` then the 
variables in that context will be returned by short name. The problem with 
doing that is that you've make those private symbols and functions 
accessible. To minimize that problem, use a Block.

Block[{$ContextPath = Append[$ContextPath, "DiscreteMath`Tree`Private`"]},
   Print@Trace[TreeFind[t, 3]]
   ]

Inside the Block short names are used. Outside the Block full names are used.

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"

Spend less time searching and more time finding.
http://www.wz.com/internet/Mathematica.html



  • Prev by Date: Re: J/Link
  • Next by Date: Re: Work with Contexts
  • Previous by thread: Re: Removing the Context
  • Next by thread: Page setting