Permalink
Browse files

move read-edn* into clojure.edn namespace

  • Loading branch information...
1 parent 21425a6 commit c6756a8bab137128c8119add29a25b0a88509900 @richhickey richhickey committed Feb 8, 2013
Showing with 50 additions and 37 deletions.
  1. +1 −0 build.xml
  2. +3 −37 src/clj/clojure/core.clj
  3. +46 −0 src/clj/clojure/edn.clj
View
@@ -55,6 +55,7 @@
<arg value="clojure.core.protocols"/>
<arg value="clojure.main"/>
<arg value="clojure.set"/>
+ <arg value="clojure.edn"/>
<arg value="clojure.xml"/>
<arg value="clojure.zip"/>
<arg value="clojure.inspector"/>
View
@@ -3394,7 +3394,7 @@
Note that read can execute code (controlled by *read-eval*),
and as such should be used only with trusted sources.
- For data structure interop use read-edn"
+ For data structure interop use clojure.edn/read"
{:added "1.0"
:static true}
([]
@@ -3421,45 +3421,11 @@
Note that read-string can execute code (controlled by *read-eval*),
and as such should be used only with trusted sources.
- For data structure interop use read-edn-string"
+ For data structure interop use clojure.edn/read-string"
{:added "1.0"
:static true}
[s] (clojure.lang.RT/readString s))
-(defn read-edn
- "Reads the next object from stream, which must be an instance of
- java.io.PushbackReader or some derivee. stream defaults to the
- current value of *in*.
-
- Reads data in the edn format (subset of Clojure data):
- http://edn-format.org
-
- opts is a map that can include the following keys:
- :eof - value to return on end-of-file. When not supplied, eof throws an exception.
- :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
- When not supplied, only the default-data-readers will be used.
- :default - A function of two args, that will, if present and no reader is found for a tag,
- be called with the tag and the value."
-
- {:added "1.5"}
- ([]
- (read-edn *in*))
- ([stream]
- (read-edn {} stream))
- ([opts stream]
- (clojure.lang.EdnReader/read stream opts)))
-
-(defn read-edn-string
- "Reads one object from the string s. Returns nil when s is nil or empty.
-
- Reads data in the edn format (subset of Clojure data):
- http://edn-format.org
-
- opts is a map as per read-edn"
- {:added "1.5"}
- ([s] (read-edn-string {:eof nil} s))
- ([opts s] (when s (clojure.lang.EdnReader/readString s opts))))
-
(defn subvec
"Returns a persistent vector of the items in vector from
start (inclusive) to end (exclusive). If end is not supplied,
@@ -5918,7 +5884,7 @@
"Defaults to true (or value specified by system property, see below)
***This setting implies that the full power of the reader is in play,
including syntax that can cause code to execute. It should never be
- used with untrusted sources. See also: read-edn.***
+ used with untrusted sources. See also: clojure.edn/read.***
When set to logical false in the thread-local binding,
the eval reader (#=) and record/type literal syntax are disabled in read/load.
View
@@ -0,0 +1,46 @@
+; Copyright (c) Rich Hickey. All rights reserved.
+; The use and distribution terms for this software are covered by the
+; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+; which can be found in the file epl-v10.html at the root of this distribution.
+; By using this software in any fashion, you are agreeing to be bound by
+; the terms of this license.
+; You must not remove this notice, or any other, from this software.
+
+(ns ^{:doc "edn reading."
+ :author "Rich Hickey"}
+ clojure.edn
+ (:refer-clojure :exclude [read read-string]))
+
+(defn read
+ "Reads the next object from stream, which must be an instance of
+ java.io.PushbackReader or some derivee. stream defaults to the
+ current value of *in*.
+
+ Reads data in the edn format (subset of Clojure data):
+ http://edn-format.org
+
+ opts is a map that can include the following keys:
+ :eof - value to return on end-of-file. When not supplied, eof throws an exception.
+ :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
+ When not supplied, only the default-data-readers will be used.
+ :default - A function of two args, that will, if present and no reader is found for a tag,
+ be called with the tag and the value."
+
+ {:added "1.5"}
+ ([]
+ (read *in*))
+ ([stream]
+ (read {} stream))
+ ([opts stream]
+ (clojure.lang.EdnReader/read stream opts)))
+
+(defn read-string
+ "Reads one object from the string s. Returns nil when s is nil or empty.
+
+ Reads data in the edn format (subset of Clojure data):
+ http://edn-format.org
+
+ opts is a map as per clojure.edn/read"
+ {:added "1.5"}
+ ([s] (read-string {:eof nil} s))
+ ([opts s] (when s (clojure.lang.EdnReader/readString s opts))))

0 comments on commit c6756a8

Please sign in to comment.