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.

N.B. I have bitten the bullet, and I am going through Leonid Shifrin's "Mathematica Programming: An Advanced Introduction." (Which needs no introduction in this forum)

One question I have: could one establish that a symbol has a built-in rules, based on DownValues or related functions?

For example:

Unprotect[Sin]
Sin[x_Integer] := Sin[N[x]]
Protect[Sin]

Sin[1]
(* 0.841471 *)
DownValues[Sin]
(* HoldPattern[Sin[x_Integer]] :> Sin[N[x]] *)

Hey, where are the built-in rules for Sin?

share|improve this question
9  
Built-in rules for system functions may indeed have DownValues, SubValues etc, but they are not seen and not accessible from the top level. You may indirectly interact with them (and possibly change their behavior) using Block, and you can also see them in action sometimes when tracing evaluation with TraceInternal -> True, but this seems to be as much as one can say about them from the top-level. Some functions also do have some number of top-level rules - those usually have the ReadProtected attribute set. You can see those rules if you remove the attribute. –  Leonid Shifrin Jul 7 '13 at 16:42
    
@Leonid So the fact that no DownValues (or other definitions) are visible does not necessarily mean that the function is not fully implemented in Mathematica then? I was never sure about this point. (Not that it makes much practical difference for me.) –  Szabolcs Jul 8 '13 at 8:16
    
@Szabolcs I believe this is true. In general, built-in functions may have both lower-level (inaccessible) and top-level definitions. –  Leonid Shifrin Jul 8 '13 at 13:08
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.