0

Given the system operator TensorContract I can define a new one, TensorContractLazy with the attribute HoldAll, which does some some optimizations, but whose definition still depends on the original System`TensorContract for some cases.

If I load old programs, however, they will not benefit from this because they do not use TensorContractLazy. I would like, if possible, in the current namespace, a way for my function, TensorContractLazy, to be called instead of System`TensorContract when evaluating TensorContract. This would allow old programs to be run with this new definition without changing them. However. I'm not sure if this is possible, or how it could be done.

user3257842
  • 872
  • 4
  • 7
  • You can try Block the codes like Block[{TensorContract= TensorContractLazy},codes] – Lacia Oct 06 '22 at 13:57
  • Module works better than Block here because Module does not replace the original TensorContract used in the definition of TensorContractLazy . However, it would be nice to be able to execute the old codes with TensorContractLazy, and without having to surround them with a Module. – user3257842 Oct 06 '22 at 14:05
  • Yes. That will work. I just need to change the Attributes of the function along with the $overwrite variable when in the block. – user3257842 Oct 06 '22 at 15:30

0 Answers0