Skip to content

Commit 60fe020

Browse files
committed
add more weird characters
1 parent 3148afa commit 60fe020

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

content/guides/weird_characters.adoc

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,88 @@ want to print the new value every time it changes
531531
`add-watch` takes four arguments, but in our case we only really care about the
532532
last argument - the new value of the atom.
533533

534+
== #? - Standard Reader conditional
535+
536+
Reader conditionals are designed to allow
537+
different dialects of Clojure to share common code. The standard reader
538+
conditional behaves similarly to a traditional `cond`. The syntax for usage
539+
is `#?` and looks like:
540+
[source,clojure]
541+
----
542+
#?(:clj (Clojure expression)
543+
:cljs (ClojureScript expression)
544+
:cljr (Clojure CLR expression)
545+
:default (fallthrough expression))
546+
----
547+
* <<xref/../reader_conditionals#,Reader conditonals>>
548+
549+
== #@ - Splicing Reader conditional
550+
551+
The syntax for a splicing reader conditional is `#?@`. It is used to splice
552+
lists into the containing form. So the Clojure reader would read this:
553+
[source,clojure]
554+
----
555+
(defn build-list []
556+
(list #?@(:clj [5 6 7 8]
557+
:cljs [1 2 3 4])))
558+
----
559+
as this:
560+
[source,clojure]
561+
----
562+
(defn build-list []
563+
(list 5 6 7 8))
564+
----
565+
* <<xref/../reader_conditionals#,Reader conditonals>>
566+
567+
== #: Map Namespace Syntax
568+
569+
Map namespace syntax was added in Clojure 1.9 and is used to specify a default
570+
namespace context for keys in the map using a `#:ns` prefix, where _ns_ is the
571+
name of a namespace and the prefix precedes teh opening brace `{` of the map.
572+
573+
For example, the following map literal with namespace syntax:
574+
[source,clojure]
575+
----
576+
#:person{:first "Han"
577+
:last "Solo"
578+
:ship #:ship{:name "Millenium Falcon"
579+
:model "YT-1300f light freighter"}}
580+
----
581+
is read as:
582+
[source,clojure]
583+
----
584+
{:person/first "Han"
585+
:person/last "Solo"
586+
:person/ship {:ship/name "Millenium Falcon"
587+
:ship/model "YT-1300f light freighter"}}
588+
----
589+
590+
* <<xref/../../reference/reader#,Reader>>
591+
592+
== Auto Resolving Namespace Syntax
593+
594+
`#::` can be used to auto-resolve namespaces with the same semantics as
595+
auto-resolved keywords.
596+
597+
* <<xref/../../reference/reader#,Reader>>
598+
599+
== #= Reader eval
600+
601+
`#=` allows the reader to evaluate the following form.
602+
Examples
603+
[source,clojure]
604+
----
605+
#=123
606+
;;=> 123
607+
608+
#="foo"
609+
;;=> foo
610+
611+
(def foo 1)
612+
#='foo
613+
;;=> 1
614+
----
615+
534616
[]
535617
====
536618
Many thanks to everyone who has contributed ideas and [the copious amounts of]

0 commit comments

Comments
 (0)