Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Code

FullForm[Hold[?name]]

Syntax::bktmcp: Expression "Hold[?name]]" has no closing "]".

Syntax::sntxi: Incomplete expression; more input is needed .

Question

This is exercise 3.2 (page 47) of Power Programming w/ Mathematica

The task is:

"determine the internal representation of the expressions ?name and ??name"

The above is what I tried. It failed. How do I win?

share|improve this question
2  
@term-rewritica - you have Wagner's book? You lucky thing - mine was borrowed by someone years ago and never seen again. –  Verbeia Jul 10 '12 at 7:28
    
@Verbeia: It's a most intense reading. Reminds me of the first time I read SICP. –  user1602 Jul 10 '12 at 8:21
    
@Verbeia I do have a copy of that one too (ironically, bought from Amazon fo $40 in 2004, when I just started learning Mathematica as a programming language - and I had no idea about the usefulness of the book at the time, it was a blind purchase). I was lucky to not give it to anyone (well, no one asked). –  Leonid Shifrin Jul 10 '12 at 10:16
1  
@term-rewritica Actually, Roman Maeder's books are more intense reading to me. I think, Wagner wrote his book on just the right level, for someone who knows some Mathematica and wants to bring their M skills to the next level. Can be a little hard to read for a complete beginner, but at least you don't have to read between the lines ( which is what happens all the time with Maeder's books - which is why they are great for experienced users). Wagner's book is still my favorite book on M programming. –  Leonid Shifrin Jul 10 '12 at 10:22
    
@Leonid: Amazon lists 4 RM books. Do you have a recommendation for order to read them in? –  user1602 Jul 10 '12 at 17:57

2 Answers 2

up vote 18 down vote accepted

To programmatically find the internal representation of the shortforms, you can use MakeExpression, which gives the result wrapped in HoldComplete. Here's an example:

MakeExpression@"?name"
(* HoldComplete[Information["name", LongForm -> False]] *)

MakeExpression@"??name"
(* HoldComplete[Information["name", LongForm -> True]] *)
share|improve this answer

Here are a couple of alternatives to R.M's method for seeing what Mathematica makes of input.

The input forms of every line entered are stored in the DownValues of In.
Starting with a new session or after using Quit[], evaluating each in a separate Cell:

?Mod

??Plus

DownValues[In]
{HoldPattern[In[1]] :> Information["Mod", LongForm -> False], 
 HoldPattern[In[2]] :> Information["Plus", LongForm -> True], 
 HoldPattern[In[3]] :> DownValues[In]}

Alternatively you could set a $Pre function to echo input:

$Pre = Function[, Print@Unevaluated@#; #, HoldAll];

?Plus
Information["Plus", LongForm -> False]

x+y+z represents a sum of terms.  >>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.