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

Float support #115

Merged
merged 9 commits into from
Feb 10, 2022
Merged

Float support #115

merged 9 commits into from
Feb 10, 2022

Conversation

brson
Copy link
Contributor

@brson brson commented Feb 8, 2022

I found myself wanting floats for dogfooding the repl.

This is using the almost unused and unmaintained eq_float crate to store Eq-implementing floats in the IR. I'm happy to do something else.

Fixes #64

@netlify
Copy link

netlify bot commented Feb 8, 2022

✔️ Deploy Preview for dada-lang ready!

🔨 Explore the source changes: 8576694

🔍 Inspect the deploy log: https://app.netlify.com/sites/dada-lang/deploys/620490a3ba40780008161d07

😎 Browse the preview: https://deploy-preview-115--dada-lang.netlify.app

@brson
Copy link
Contributor Author

brson commented Feb 8, 2022

This is missing a negative test case for "1." I'll add it later.

@brson
Copy link
Contributor Author

brson commented Feb 9, 2022

I added a test that parsing floats without decimals is an error. The span pointing to the dot is not quite right, but I don't know how to fix it offhand.

Copy link
Member

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This seems good!

Can we add a test for 1_000.222_444 or something like that?

components/dada-ir/src/code/syntax.rs Show resolved Hide resolved
# nan != nan
var nan1 = 0.0 / 0.0
var nan2 = 0.0 / 0.0
if nan1 == nan2 {
Copy link
Member

Choose a reason for hiding this comment

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

Man, I am so tempted to change this behavior and adopt IEEE total order for floats. =)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll open an issue.

@@ -0,0 +1,5 @@
fn main() {
a = 1.
Copy link
Member

Choose a reason for hiding this comment

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

Should we permit this? People sometimes do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no opinion.

@brson
Copy link
Contributor Author

brson commented Feb 10, 2022

This seems good!

Can we add a test for 1_000.222_444 or something like that?

I've added this test. Note the syntax supports trailing underscores like 1_.2_. This is consistent with Rust.

Copy link
Member

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Nice!

@nikomatsakis
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 10, 2022

@bors bors bot merged commit 3b7e1e8 into dada-lang:main Feb 10, 2022
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.

Interpret float binops
2 participants