# Question

Is there a way to define a function which evaluates itself regardless of HoldAll, HoldFirst, ... ?

# Background

I'm writing a function which makes it easier to document other functions using ::usage, SyntaxInformation and code completion. I also use code generation and I want to document the generated code.

Therefore I need to define new symbols with a usage message and remove them like this:

(* I already get an error message here since Evaluate wants to evaluate
Symbol[name] but name is not a string yet *)
NewSymbol[name_String] := Evaluate[Symbol[name]];

Remove[NewSymbol["test"]] (* DOES NOT WORK *)
NewSymbol["test"]::usage = "This is a test"; (* DOES NOT WORK *)

(* In order to make it work I have to use an additional Evaluate*)

(* The same is true if I want to use Remove *)
Remove[Evaluate[NewSymbol["test"]]]

Evaluate[NewSymbol["test"]]::usage = "This is a test";

• What is the purpose of this? What goal is it intended to serve? With that info, answers might be more helpful. Apr 8 '20 at 13:08
• @MariusLadegårdMeyer Thank you for your comment. Is the intention clear now? Apr 8 '20 at 13:16

Stay away from Evaluate altogether and use With to inject into functions that hold their arguments:
createSymbolAndSetUsage[sym_String, usage_String] := With[