# How to protect pure functions

I have some pattern functions and pure function in my package. If i set attributes Protected and ReadProtected. My pattern function definition is hidden from end user but for pure function just evaluating its name prints its definition. I believe pure function are storing their definition as OwnValues as opposed to DownValues. Is there a way i can make them available for use but hide their definition?

• Yes and no. You can do this: f = Function[x, x^2]; SetAttributes[f, ReadProtected]; ?? f and you see that also the OwnValues of f are hidden from Definition and FullDefinition. But f will always evaluate to a Function and of course, one can see what it does. – Henrik Schumacher Jun 14 '18 at 13:22
• So it means i have to rewrite all my pure functions as patterns. Also can someone confirm if any of the builtin functions are written as pure functions. – user13892 Jun 14 '18 at 15:27
• Note that ReadProtected does not really protect from reading. My favorite example is Needs["GeneralUtilities"];PrintDefinitions[HighlightGraph]`. – Henrik Schumacher Jun 14 '18 at 15:35