StringPartition[n_Integer, d_Integer] := Function[str, StringPartition[str, n, d]]
results in the following error on my machine:
SetDelayed::write: Tag StringPartition in StringPartition[n_Integer,d_Integer] is Protected.
I have added operator definitions to many other built-in functions using this methodology and StringPartition is the first one that gives me this error.
Please let me know if I’m missing something here or if this error message is a bug?
I am familiar with Curry, however I would like to avoid defining a new symbol (op in your example) and instead would like to add an operator definition to the existing, built-in symbol StringPartition.
Yes you are right, the unexpected behavior I was referring to in my question is exactly the fact that StringPartition for some reason automatically re-protects itself.
Do you know why this is or how to go about fixing it?
If you look at the definition of StringPartition, you’ll see that it is just a stub loading a package, not a real function (in a fresh kernel, of course):
This explains the behavior you observe. The workaround is to preload the package before making any new definitions as I made above. But remember that modifying built-in functions is dangerous and isn’t recommened until you know exactly what you do…