Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6986193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:46:40+00:00 2026-05-27T18:46:40+00:00

Occasionally we like to look into how certain System` functions are defined (when they’re

  • 0

Occasionally we like to look into how certain System` functions are defined (when they’re written in Mathematica). This question is about the best way to do that.

Points to keep in mind:

  • Of couse ReadProtected needs to be removed first.

  • Builtins usually need to be used at least once before they get loaded into the kernel. Is a single simple invocation usually sufficient for this when they have extended functionality (e.g. through options)?

  • Information (??) gives the definition in a hard-to-read format (no indentation, and all private context names prepended). What is the best way to get rid of the context names, and get formatted code?

    One idea for getting rid of certain contexts is Block[{$ContextPath = Append[$ContextPath, "SomeContext`Private`"], Information[symbol]]. Code can be auto-formatted using Workbench. Some issues remain, e.g. Information doesn’t quote strings, preventing the code from being able to be copied into Workbench.

Generally, I’m interested in how people do this, what methods they use to make the code of builtins as easy to read as possible.

Use case: For example, recently I digged into the code of RunThrough when I found out that it simply doesn’t work on Windows XP (turns out it fails to quote the names of temp files when the path to them contains spaces).


Update: It appears that there used to be a function for printing definitions without context prepended, Developer`ContextFreeForm, but it’s not working any more in newer versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:46:40+00:00Added an answer on May 27, 2026 at 6:46 pm

    Regarding the pretty-printing: the following is a very schematic code which builds on the answer of @Mr.Wizard to show that a few simple rules can go a long way towards improving the readability of the code:

    Internal`InheritedBlock[{RunThrough},
       Unprotect[RunThrough];
       ClearAttributes[RunThrough, ReadProtected];
       Block[{$ContextPath = Append[$ContextPath, "System`Dump`"]},
          With[{boxes = ToBoxes@ DownValues[RunThrough]},
             CellPrint[Cell[BoxData[#], "Input"]] &[
                boxes /. 
                f_[left___, "\[RuleDelayed]", right___] :> 
                     f[left, "\[RuleDelayed]", "\n", right] //.
               {
                 RowBox[{left___, ";", next : Except["\n"], right___}] :> 
                     RowBox[{left, ";", "\n", "\t", next, right}],
                 RowBox[{sc : ("Block" | "Module" | "With"), "[", 
                   RowBox[{vars_, ",", body_}], "]"}] :>
                     RowBox[{sc, "[", RowBox[{vars, ",", "\n\t", body}], "]"}]
               }]]]]
    

    This is for sure not a general solution (in particular it won’t work well on deeply nested functional code without many separate statements), but I am sure it can be improved and generalized without too much trouble to cover many cases of interest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I occasionally write code something like this: // file1.cpp #define DO_THIS 1 #if DO_THIS
I occasionally see the list slice syntax used in Python code like this: newList
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I've got image tags that look like this: <img src=/path/to/my/image.jpg /> But when I
Slightly related question to this one and this one . Basically, I would like
I occasionally run a bash command line like this: n=0; while [[ $n -lt
I have a long-running multithreaded program, and I'd like to occasionally like to call
Like it or not, occasionally you have have to write tests for classes that
Occasionally, on a ASP (classic) site users will get this error: [DBNETLIB][ConnectionRead (recv()).]General network
Occasionally I like to spend some time looking at the .NET code just to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.