Liking cljdoc? Tell your friends :D

org.clojars.evenmoreirrelevance.doubledot


class-edn-read-roundtrips?clj

(class-edn-read-roundtrips? x)
source

end-dot-err-explanationclj

source

nicknamesclj

(nicknames {:as nicks->classes})
(nicknames ns_ {:as nicks->classes})

Sets nicknames for the given classes. The classes must belong to a package and must pr to a simple-symbol.

Sets nicknames for the given classes.
The classes must belong to a package and must `pr` to a simple-symbol.
sourceraw docstring

ns-nicknamesclj

(ns-nicknames ns_)

Gets the nicknames in effect in ns_. Note that you will get a fresh map every time you call this.

Gets the nicknames in effect in `ns_`.
Note that you will get a fresh map every time you call this.
sourceraw docstring

ns-shorthandsclj

(ns-shorthands ns_)

Gets the shorthands in effect for the ns_. Note that you get a fresh map every time you call this.

Gets the shorthands in effect for the `ns_`. 
Note that you get a fresh map every time you call this.
sourceraw docstring

read-shortenedclj

(read-shortened frm)

The reader for the #+! reader-macro.

Walks without macroexpanding, and processes simple-symbols beginning by .. and symbols whose ns begins with .. by substituting shorthands for package qualifications and nicknames for classes as defined in the current ns. Processing happens in lists, maps and vecs too, as well as all meta.

Adding ^::l to anything's meta will spare that form from processing, and quoted forms are spared too. However, no further attempts are made to be nicer at this stage, and note that due to readers being processed in post-order as opposed to pre-order, a #+! reader macro in an otherwise-spared subform will be processed anyway.

This will break if all the following are true:

  • a symbol is fed to a macro/special form which doesn't evaluate it;
  • the symbol is shorthandable;
  • the macro doesn't treat the symbol as a var/class name (which is the intended use case for shorthanding...).

An immediate example is (let [..my-short.Class 3] nil) ;=> compile time error, but the .. prefix considered distinctive enough and the case is deemed obscure enough to consider this worthwhile, especially since this is a reader-macro where the problem should immediately be apparent.

Processing works as follows: If the ns/name ends with ., then an error is thrown(1). Then, the prefix .. is elided, and then an attempt is made to replace the whole namespace or name with the qualified name of the class with that nickname. If that fails, the longest shorthand which is a proper prefix of the ns/name which ends in a dot minus the dot is replaced by its long hand form. If that also fails, an error is thrown. Finally, if the final output turned symbol can't resolve to a class, then an error is thrown.

Consider for instance:

(shorthands '{ju java.util ju.c java.util.Concurrent ..java.util SOMETHING-REALLY-WRONG})
#+! (nichnames {'ArrList ..ju.ArrayList})
#+! (.getName ..j.u.c.ConcurrentHashMap) ; => "java.util.concurrent.ConcurrentHashMap" 
#+! (.get (..ArrList/new [1 2 3]) 2) ; => 3 (emits same code as `(java.util.ArrayList. [1 2 3])`)
#+! #(doto ^..j.u.List % (.add 4)) ; no reflection emitted (traverses `:tag` meta)
#+! #+! #+! ..j.u.List ; => java.util.List (idempotent)

(1) this is because of potentially unintuitive behaviors with how package qualifiers are detected, and due to the necessity to have a special case for nickname expansion. The choice was made to KISS.

The reader for the `#+!` reader-macro.

Walks without macroexpanding, and processes simple-symbols beginning by `..`
and symbols whose `ns` begins with `..` by substituting shorthands for package
qualifications and nicknames for classes as defined in the current ns.
Processing happens in lists, maps and vecs too, as well as all meta.

Adding ^::l to anything's meta will spare that form from processing, 
and quoted forms are spared too. 
However, no further attempts are made to be nicer at this stage,
and note that due to readers being processed in post-order as opposed to pre-order,
a #+! reader macro in an otherwise-spared subform will be processed anyway.

This will break if all the following are true:
- a symbol is fed to a macro/special form which doesn't evaluate it;
- the symbol is shorthandable;
- the macro doesn't treat the symbol as a var/class name 
  (which is the intended use case for shorthanding...).

An immediate example is `(let [..my-short.Class 3] nil) ;=> compile time error`, 
but the `..` prefix considered distinctive enough and the case is deemed obscure enough 
to consider this worthwhile, especially since this is a reader-macro
where the problem should immediately be apparent.

Processing works as follows: If the ns/name ends with `.`, then an error is thrown(1).
Then, the prefix `..` is elided, and then an attempt is made to replace
the whole namespace or name with the qualified name of the class with that nickname.
If that fails, the longest shorthand which is a proper prefix of the ns/name
which ends in a dot minus the dot is replaced by its long hand form. If that also fails,
an error is thrown. Finally, if the final output turned symbol can't resolve to a class,
then an error is thrown.

Consider for instance:
```
(shorthands '{ju java.util ju.c java.util.Concurrent ..java.util SOMETHING-REALLY-WRONG})
#+! (nichnames {'ArrList ..ju.ArrayList})
#+! (.getName ..j.u.c.ConcurrentHashMap) ; => "java.util.concurrent.ConcurrentHashMap" 
#+! (.get (..ArrList/new [1 2 3]) 2) ; => 3 (emits same code as `(java.util.ArrayList. [1 2 3])`)
#+! #(doto ^..j.u.List % (.add 4)) ; no reflection emitted (traverses `:tag` meta)
#+! #+! #+! ..j.u.List ; => java.util.List (idempotent)
```

(1) this is because of potentially unintuitive behaviors with how package qualifiers are detected,
and due to the necessity to have a special case for nickname expansion. The choice was made to KISS.
sourceraw docstring

read-shortened-symclj

(read-shortened-sym frm)

The reader for the #-! reader-macro.

Similar behavior to the #+! reader-macro, but only processes a single symbol (without even walking its meta) and doesn't need the .. prefix.

The reader for the #-! reader-macro. 

Similar behavior to the #+! reader-macro, 
but only processes a single symbol (without even walking its meta) 
and doesn't need the `..` prefix.
sourceraw docstring

shorthandsclj

(shorthands {:as shorthand->package})
(shorthands ns_ {:as shorthand->package})

Defines shorthands in ns_ (default ns). Fails atomically if it would override a shorthand.

Defines shorthands in `ns_` (default *ns*). 
Fails atomically if it would override a shorthand.
sourceraw docstring

unnicknameclj

(unnickname [:as more])
(unnickname ns_ [:as more])
source

unshorthandclj

(unshorthand more)
(unshorthand ns_ [& more])

Removes shorthands in ns (default ns). Will ignore nonexisting shorthands.

Removes shorthands in `ns` (default *ns*). Will ignore nonexisting shorthands.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close