Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't read clojure ratios #34

Closed
martintrojer opened this issue Jun 17, 2013 · 2 comments
Closed

doesn't read clojure ratios #34

martintrojer opened this issue Jun 17, 2013 · 2 comments

Comments

@martintrojer
Copy link

;; clojure defacto-standard edn reader
user=> (clojure.edn/read-string "1/2")
1/2
// scala
val p = newParser(defaultConfiguration())
val r = p.nextValue(newParseable("{:x 1/2}")).asInstanceOf[java.util.Map[Keyword,Any]].toMap

us.bpsm.edn.EdnSyntaxException: Not a number: '1/'.
    at us.bpsm.edn.parser.ScannerImpl.readNumber(ScannerImpl.java:434)
    at us.bpsm.edn.parser.ScannerImpl.scanNextToken(ScannerImpl.java:153)
    at us.bpsm.edn.parser.ScannerImpl.nextToken(ScannerImpl.java:61)
        ...
@bpsm
Copy link
Owner

bpsm commented Jun 17, 2013

Clojure rationals are not valid edn numbers as far as I can tell.

https://github.com/edn-format/edn

edn supports:

  • integers
  • arbitrary precision integers
  • floating point numbers
  • arbitrary precision floating point numbers

Rationals are not mentioned in the spec.

On the other hand, clojure.edn/read accepts rationals without complaint (see EdnReader.java) but that's probably an accident resulting from the fact that EdnReader.java is basically a copy-paste of LispReader.java with some stuff removed.

If edn-java did support reading rational numbers, what type would you expect the result to be? Java doesn't have a standard representation for rational numbers that I'm aware of.

See also edn-format/edn#47.

@bpsm
Copy link
Owner

bpsm commented Mar 1, 2014

Will not implement reading rationals as this is not in the spec.

@bpsm bpsm closed this as completed Mar 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants