swadey / LispSyntax.jl

lisp-like syntax in julia
Other
231 stars 24 forks source link

Floats are not recognized? #13

Closed zlaus closed 8 years ago

zlaus commented 8 years ago

trying to input a floating point variable gives an Error. Same when using LispREPL

julia> lisp"(+ 3.0 2.0)" ERROR: UndefVarError: .0 not defined

or am i simply missing something?

by the way: awesome work! Julia with s expressions has the potential to be mindblowing awesome :)

Ismael-VC commented 8 years ago

@zlaus the documentation and tests are still sparce and just starting, sorry about that, there is only one example of this in the tests:

@expect LispSyntax.read("3.0d") == 3.0

The literal for 64 bits floating points values as of now is currently postfixed with a d (I was going to suggest this weekend to let it be the same as Julia as you expected), feel free update the documentation yourself if you like, it can be done from the web interface.

I'll have spare time to document all the literals until the weekend.

Thanks for reporting this.

@swadey could you change the title of this issue so as not to forget to document this?

Ismael-VC commented 8 years ago
julia> using LispREPL

lisp> (+ 3.0d 2.0d)
5.0
Ismael-VC commented 8 years ago

This is the current definition for parsing doubles:

doubley = p"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?[dD]" > (x -> parse(Float64, x[1:end-1]))
swadey commented 8 years ago

yeah, ismael is right. The current syntax for floats is 3.0f and doubles 3.0d.

zlaus commented 8 years ago

Thank you! Had to be somthing trivial. I created a pull request and added this information to the quick intro :)