I found the behavoir have changed. All symbol in System` is kernel funtion(include those your custom funtion)



If you run


You will get the definition of ShearingMatrix.But when you run


You will get a information that the UnitStep is a kernel function.Can we make a custom function,like KernelFunctionQ, to judge the function in context of System` is a kernel function or not?

  • 5
    $\begingroup$ Wouldn't PrintDefinitions[PrintDefinitions] tell you how that's implemented? $\endgroup$ – ilian Oct 30 '16 at 16:08
  • $\begingroup$ @ilian Wow,I have not seen your comment before this.I do it just now.Get a chunk code.Maybe it deserve dig.Thanks in advance. $\endgroup$ – yode Dec 12 '16 at 22:47
  • $\begingroup$ @yode From my experience HasOwnCodeQ, HasDownCodeQ, HasSubCodeQ, HasUpCodeQ, HowPrintCodeQ will only return true if it's implemented internally. They don't catch OwnValues, DownValue, SubValues, UpValues, or FormatValues. $\endgroup$ – b3m2a1 Sep 17 '17 at 6:49
  • $\begingroup$ @b3m2a1 No,see here $\endgroup$ – yode Sep 17 '17 at 9:43

This is wonderful comment I have to say.I have not think about it before this.As the promption,I get into the page of GeneralUtilities`PrintDefinitions,Then I click Definitions->KernelPlaceholderDefs,I have got this information:

KernelPlaceholderDefs[sym_Symbol] := If[!HasAnyCodesQ[sym],
                HoldPattern[sym] :> $KernelFunctionPlaceholder
				HoldPattern[sym[___]] :> $KernelFunctionPlaceholder
                HoldPattern[sym[___][___]] :> $KernelFunctionPlaceholder
				HoldPattern[_[___, sym, ___]] :> $KernelFunctionPlaceholder
                HoldPattern[Format[sym, _]] :> $KernelFunctionPlaceholder

Attributes[KernelPlaceholderDefs] := {HoldAll};

So the function System`Private`HasAnyCodesQ can judge the function is kernel function or not.Maybe is all of in a local file GeneralUtilities`PackageScope`$KernelFunctionPlaceholder but I don't know how to open it,we can get it all by following code:

kernelFunctions = 


A total of $\color{red}{1341}$ kernel function that we can not use GeneralUtilities`PrintDefinitions to get it's definition.And we can see the kernel function is classifid 5 kinds by WR,such as HasOwnCodeQ,HasDownCodeQ,HasSubCodeQ,HasUpCodeQ and HasPrintCodeQ.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.