Fork me on GitHub
#core-typed
<
2022-10-04
>
Martin Jul10:10:58

A question about defalias (using Typed Clojure 1.0.32). Is there a way to make a defalias using the symbolic name of a record (`ann-record`) from another namespace? It accepts the the JVM classname of the record, e.g. (t/defalias Foo that.other.namespace.full_name.Foo) as an alias for something in ns that.other.namespace.full-namewith a (t/ann-record Foo ....) for a (defrecord Foo ...) . Is there way to write (t/defalias F fnalias/Foo) or is this just for non-record types?

ambrosebs18:10:29

Hi @U040NGRHA4B have you tried importing the record into your namespace? Classes should resolve using the same rules as normal.

Martin Jul09:10:56

@U055XFK8V Thanks for the tip. Importing the type Foo does makes the type to be available to the type checker, so I don't have to defaliasit in the local namespace.

Martin Jul09:10:26

(similar to the fully qualified name Java class name that I used)

Martin Jul09:10:30

Now, if I understand correctly: I can reference ann type annotations using the normally using their Clojure names with the require syntax and aliases. However, ann-record type annotations must be reference using the corresponding Java class name of the record itself (e.g. underscores instead of hyphens in namespaces) and cannot reference the symbolic (Clojure) name given to ann-record

ambrosebs18:10:29

exactly. The intention was that you'd refer to the symbols "normally" in both cases, since defalias's used to intern vars.