3 ms·
Not really, read-line is more or less equivalent to python's input method. It reads raw input and tries to evaluate it. Passing false makes it safer for readin
by stonemetal 14y ago
Not really, read-line is more or less equivalent to python's input method. It reads raw input and tries to evaluate it. Passing false makes it safer for reading data structures, but it will still try to execute Java constructors so that your data is correctly initialized. To be safe you need to use other methods i.e. edn(extensible data notation).
edn limits what is allowed to a safe subset of what read-line will allow, all of the base clojure types and collection types (maps, lists, sets, vectors) are allowed, Java isn't.
- mjw 14y ago> It reads raw input and tries to evaluate it Not quite. It reads raw input and tries to build a syntax tree from it. Unfortunately reader macros in clojure allow all sorts of objects to form part of said syntax tree and arbitrary-ish code to run at parse time to instantiate them. But the main job of the reader isn't to evaluate code.