Skip to content

Conversation

@jetmonk
Copy link

@jetmonk jetmonk commented Dec 8, 2019

  • *allow-nan* - allows parsing of Nan,Inf,Infinity into 'nan 'plus-infinity 'minus-infinity

  • *yason-float-parser* - allows separate float parser for floats

  • *yason-float-type* - now 'double-float - sets output type of floats

  • *allow-loose-floats* - allow floats (and Inf,NaN) with leading +, and allow d,D to be symbol for exponent in floats (not in JSON standard)

  • add float validation function to avoid interning of (eg) "0dd+d" by lisp reader when reading a float

* \*allow-nan\*  - allows parsing of Nan,Inf,Infinity into 'nan 'plus-infinity 'minus-infinity

* \*yason-float-parser\*  - allows separate float parser for floats

* \*yason-float-type\* - now 'double-float - sets output type of floats

*  \*allow-loose-floats\* - allow floats (and Inf,NaN) with leading +, and allow d,D to be symbol for exponent in floats (not in JSON standard)

* add float validation function to avoid interning of (eg) "0dd+d" by lisp reader when reading a float
@jetmonk
Copy link
Author

jetmonk commented Dec 15, 2019

I thought of doing this, but I have my own older parse-float (with same name, unfortunately). Also, I thought that the built-in Lisp reader has the advantage of being rigorously read-write consistent, unlike 3rd party libraries, which might make it a better default. So I put a sanity check in front of the Lisp float parser, and made the use of any other parse-float optional using eg

(setf yason:*yason-float-parser* 
    (lambda (string)  (parse-float:parse-float string :type 'single-float)))



#:*allow-nan*
#:*yason-float-parser*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop the yason- prefix - the package should make clear where the symbols are from.

#:true
#:false
#:null
#:nan
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About :NAN and ±∞ I'd like to see what CSR is doing about them - we'll want to be compatible. (See http://www.sbcl.org/sbcl20/ for the one-line note.)




;; verify that the buffer contains a float, and is not a symbol like
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like this code-duplication - first checking for validity, and then parsing, with a lot of code overlap.

That's why I asked about using PARSE-FLOAT - use an IGNORE-ERRORS around it to check or so, I hope this could be done in a single pass.

Let's see what CSR comes up with.

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

Successfully merging this pull request may close these issues.

2 participants