I'll first state the main question of this, what follows afterwards are some of my thoughts/attempts at fixing it and additional questions about possible improvements (getting an answer to those would be great of course, but I'll try to focus the question on one issue)
I'm trying to incorporate a modified version of this answer into my utility package, but I have problems attaching usage information to it. The current version looks like this:
•::usage="...";
•Proxy::usage=•::usage
•/:Information[•,___]:=Information@•Proxy
•/:HoldPattern[•::usage]:=•Proxy::usage
•/:h_[pr___,•,pst___]/;Length@HoldAll[pr,pst]>0:=Function[Null,h[pr,##,pst],{HoldAll}]
Due to the second and third line, the following works:
Information[•]
but this does not:
?•
First, I assumed that ?
was simply an alias for Information
, but this doesn't seem to be the case. Tracing the second call (Trace@?•
) reveals that the symbol •
gets immediately replaced by "•"
, the upvalues only breaking things deeper inside Information
. Even HoldComplete
is not enough:
HoldComplete@?•
(* HoldComplete[Information["•", LongForm -> False]] *)
Question: Is there any way to fix this, short of Unprotect
ing Information
and adding a definition for "•"
? And what is ?
? (Judging from the documentation of HoldComplete
, it seems to be an "input transformation", as anything else would have not been evaluated)
Additional notes/attempts/questions/...
The issue is that the upvalue associated with •
wreaks havoc when trying to work with the symbol itself (e.g. getting Information
or UpValues
of •
). I did a few things trying to fix this:
- Ensure that the expression has at least one more argument, since something like
f[•]
wouldn't make much sense anyway. This fixesUpValues
and similar functions - Reroute
Information
to display the usage message for•Proxy
, which has no dangerous upvalues (therefore the first example above works)
There are several problems with this, one of which is that forcing more than one argument has unforeseeable consequences if the function does anything too complicated with its argument:
f[x_] := -x > 0
f[•][3]
(* (Function[Null, -##1, {HoldAll}] > 0)[3] *)
I could of course implement a head blacklist for the upvalue of •
, but is there a way that is more elegant?