⊗ in using

I am trying to make

using TensorCast: ⊗

work. For the above I get an LoadError: "invalid \"using\" statement: expected identifier". I tried various combinations of : and ()s, what’s the right way? Eg import Base: + just works.

Is defined in TensorCast? I try importing some other function that I have seen defined in the package and I do not get any problem. However, it does not seem to find .

julia> import TensorCast: @cast

julia> import TensorCast: ⊗
WARNING: could not import TensorCast.⊗ into Main

I get

julia> using TensorCast: ⊗
ERROR: UndefVarError: ⊗ not defined

(jl_oVB8Xl) pkg> st
Status `/tmp/jl_oVB8Xl/Project.toml`
  [02d47bb6] TensorCast v0.4.6

julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
  Threads: 1 on 8 virtual cores

I figured it out: is just a placeholder that is parsed by the macro, so it does not need to be imported.

The minimal import is

using TensorCast: @cast, TensorCast

since @cast expands to calls in TensorCast so it needs the module name available (I am not sure if it is possible to implement macros that expand to functions in a module without the module name being imported).


That sounds like a bug then, the package can (should) interpolate it’s own functions and not rely on whatever names the user have in their namespace.


That’s exactly right. Like the indices the macro acts on, there is never an object of this name defined.

This is right too.