Skip to content

Commit 9dcf517

Browse files
committed
Cleaning up param-tag info
1 parent e7be68d commit 9dcf517

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

content/reference/metadata.adoc

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ Modify or reset the metadata respectively for a namespace/var/ref/agent/atom.
8181

8282
In addition to `with-meta`, there is reader support (<<reader#metadata,Metadata Reader>>) for applying metadata to the expression following it at read-time.
8383

84-
For a metadata value of type:
84+
See <<java_interop#typehints,Type Hints>> and <<java_interop#paramtags,param-tags>> for more information on how metadata is used by the compiler for method overload selection.
8585

86-
* Map: `^{:key value ...}` yields itself
87-
* Keyword: `^:key` yields `^{:key true}`
88-
* Symbol: `^AClass` or `^package.AClass` yields `{:tag package.AClass}` (also see special <<java_interop#TypeAliases,type aliases>>)
89-
* Vector: `^[AClass prim _ ...]` yields `{:param-tags [package.AClass prim _ ...]}`
90-
* *deprecated* String: `^"[Lpackage.AClass;"` yields `{:tag "[Lpackage.AClass;"}` - since 1.12, use array class symbols instead, e.g. `^package.AClass/1`
9186

92-
The `:tag` key is used to hint an objects type to the Clojure compiler. See <<java_interop#typehints,Java Interop: Type Hints>> for more information and a complete list of special type hints.
93-
94-
Since Clojure 1.12, the `:param-tags` key is used on qualified static, instance, and constructor method symbols to specify the arity and parameter types of the desired method overload. The `:param-tags` vector takes any valid `:tag` value or `_` as a placeholder for non-overloaded parameters.
95-
96-
It is possible to add multiple pieces of metadata by chaining the metadata reader macros together.
97-
For example: `^:dynamic ^ints obj` would apply both the :dynamic flag and ints type-hint to obj. Metadata chains from right to left (left takes precedence).
98-
99-
Note that metadata reader macros are applied at read-time, not at evaluation-time, and can only be used with values that support metadata, like symbols, vars, collections, sequences, namespaces, refs, atoms, agents, etc. Some important exceptions that *don't* support metadata are strings, numbers, booleans, Java objects, keywords (these are cached and can be shared within the runtime), and deftypes (unless they explicitly implement clojure.lang.IMeta).

content/reference/reader.adoc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,12 @@ Metadata is a map associated with some kinds of objects: Symbols, Lists, Vector,
141141
`^{:a 1 :b 2} [1 2 3]` yields the vector `[1 2 3]` with a metadata map of `{:a 1 :b 2}`. +
142142

143143
A shorthand version allows the metadata to be a simple symbol or string, in which case it is treated as a single entry map with a key of `:tag` and a value of the (resolved) symbol or string, e.g.: +
144-
`^String x` is the same as `^{:tag java.lang.String} x` +
144+
`^String x` is the same as `^{:tag java.lang.String} x`.
145145

146-
A shorthand version for type signatures allows the metadata to be a vector, in which case it is treated as a single entry map with a key of `:param-tags` and a value of the (resolved) type hints, a vector of `:tag` values or `_`, e.g.: `^[String long _]` is the same as `^{:param-tags [java.lang.String long _]}`.
147-
148-
Such tags can be used to convey type information to the compiler. +
146+
A shorthand version for type signatures allows the metadata to be a vector, in which case it is treated as a single entry map with a key of `:param-tags` and a value of the (resolved) type hints, a vector of `:tag` values or `_`, e.g.: `^[String long _]` is the same as `^{:param-tags [java.lang.String long _]}`. See <<java_interop#paramtags,`:param-tags`>> on how param-tags are used.
149147

150148
Another shorthand version allows the metadata to be a keyword, in which case it is treated as a single entry map with a key of the keyword and a value of true, e.g.: +
151-
`^:dynamic x` is the same as `^{:dynamic true} x` +
149+
`^:dynamic x` is the same as `^{:dynamic true} x`
152150

153151
Metadata can be chained in which case they are merged from right to left.
154152

0 commit comments

Comments
 (0)