Comments (9)
Well, project.clj
isn't technically EDN.
from babashka.
@skat-kurt I recommend using something like edamame for this, which is built into babashka as well. You can tweak whatever you want to allow in your .ednish
or .cljish
file. E.g. if you want to have EDN + regexes but never a location, you can do this:
(require '[edamame.core :as e])
(e/parse-string "..." {:regex true :location? (constantly false)})
from babashka.
@skat-kurt It's not recommended to use read-string
for reading EDN files. This is what we have clojure.edn/read-string
for. read-string
is for reading code.
from babashka.
Thanks, using clojure.edn/read-string
works perfectly (and I should have known...)
from babashka.
Nonetheless, I'll try to align bb's behavior to clj's.
from babashka.
I'll have to stick with my original work-around for now. The original file I want to read contains a regex, which edn/readstring
doesn't like
(edn/read-string "#\"test\"")
Results in the
java.lang.RuntimeException: No dispatch macro for: "
exception, mentioned in another issue as well. That behavior is identical with standard clojure though.
from babashka.
regexes aren't part of EDN, so if your file ends with .edn
I would say this is just invalid syntax
from babashka.
You are right. A pity that the clojure.edn namespace isn't symetric. I mean, there is no clojure.edn/write-string
function that could throw when serializing data to edn that cannot be expressed in it. I use pr-str
instead, which happily writes regex etc.
Some background. The "edn" files form the basis to auto-generate leiningen compatible project.clj files and some of them need :userjar-merge-with in combination with regex, as seen in the example project.clj file https://gitlab.com/technomancy/leiningen/blob/master/sample.project.clj#L436. I'll find another way to express this in the source edn files, so that they become valid edn files and take it from there.
from babashka.
I think I'll go with introducing a reader tag for regex, so that the edn files at least become valid, while edn/read-string
returns regex data. Something like the following.
(edn/read-string
{:readers {'regex re-pattern}}
"#regex \"the-pattern\"")
from babashka.
Related Issues (20)
- Resolve bb.edn when script is invoked via symlink HOT 1
- No dispatch macro for: ? HOT 9
- Embedding META-INF/bb.edn with :deps results in: Cannot run program "java"
- bb execution fails on Gentoo HOT 6
- Adding javax.net.ssl.SSLSocket and javax.net.ssl.SSLSocketFactory? HOT 33
- Static-linked binary file for armv7(32-bit) platform. HOT 1
- hash-ordered-coll not found in clojure.core HOT 1
- Try to support latest changes in at-at
- Wrapping built-in timbre/log! throws an error HOT 3
- exec-task description
- bb --version could run without a JVM HOT 3
- Can't use a lambda in a babashka's task HOT 2
- Babashka's `use-fixtures` doesn't add `:clojure.test/*-fixtures` metadata to namespace
- Dynamic var *test-out* not properly bound when clojure.test is called from within the nrepl
- bb should error when bb.edn does not contain exactly one valid form HOT 4
- Feature request: Expose flatland.ordered.set/ordered-set HOT 1
- command line separation with -- broken in several context HOT 10
- Make transcriptor work
- input redirection from shell can cause an error on startup HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babashka.