brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 109 forks source link

`within` suggests using `within` to compare two roughnums #1352

Closed jswrenn closed 6 years ago

jswrenn commented 6 years ago

n = ~1.5
within(0)(n, n)

blerner commented 6 years ago

@ds26gte this looks like it's happening in the js-numbers library, and I'm not sure why it's failing like this. within(~0)(~1, ~2) works, but within(0)(~1, ~2) fails with the error above. The same failure occurs for within-rel and within-abs. Could you look into it?

jpolitz commented 6 years ago

This is the documented behavior at

https://www.pyret.org/docs/latest/equality.html#%28part._s~3aroughnum-equality%29

I think The semantics make sense, but the error message could be a little more clear.

On Sat, Jun 30, 2018 at 7:52 AM Ben Lerner notifications@github.com wrote:

@ds26gte https://github.com/ds26gte this looks like it's happening in the js-numbers library, and I'm not sure why it's failing like this. within(~0)(~1, ~2) works, but within(0)(~1, ~2) fails with the error above. The same failure occurs for within-rel and within-abs. Could you look into it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/brownplt/pyret-lang/issues/1352#issuecomment-401545828, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHUU8XTtPH_L_-nBNnvNRdClOFzyvs_ks5uB5CKgaJpZM4U9Zff .

-- This message was sent from my phone.

blerner commented 6 years ago

New message pushed for this case: image

We can bikeshed the wording on this message a bit (pinging @shriram, @kfisler and @schanzer for input). But note that the message that comes from == (and its related operators) is now distinct from within (and its variations), when the tolerance is exact-zero, so we can improve them separately from each other.

schanzer commented 6 years ago

This is a big improvement - thanks! I only have nits to pick, and they're not even that important. I'd propose:


Pyret cannot be certain that Roughnums are the same to "exactly-zero" tolerance.
The left side was:
1
The right side was:
~1
Use a larger tolerance, or "roughly-zero" (~0) instead.```
shriram commented 6 years ago

I like Emmanuel's suggestion. Also, Jack should look it over.