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

Enhancement: Document or warn when the numerator is assumed #49

Closed
Gusted opened this issue Jan 28, 2022 · 6 comments
Closed

Enhancement: Document or warn when the numerator is assumed #49

Gusted opened this issue Jan 28, 2022 · 6 comments
Assignees

Comments

@Gusted
Copy link

Gusted commented Jan 28, 2022

When doing a division(e.g. 1/2), the provided numerator is used.

However when you don't specify the numerator(e.g. /2), calc assumes the numerator is 1 and process it with that value. I couldn't find documentation if this is a intended change or not as all calculators I've used trowed a error on such expression. Is this intended, or is this a bug?

@lcn2
Copy link
Owner

lcn2 commented Jan 28, 2022

This is an odd behavior / feature. We didn't know that calc assumed a numerator of 1.

This looks line an undocumented "feature". It does not look like it harms anything that we can think of.

Perhaps your issue should be closed with a "well noticed" comment? What do you think?

@Gusted
Copy link
Author

Gusted commented Jan 28, 2022

I'm not sure, I think it should throw a error as I'd found this error by accident when I made a typo and forgot to add a numerator the a division, which yielded in a weird result. Cross-checking on another calculator it gave me why it was yielding a weird result, the division didn't had a numerator.

Someone could have the same mistake by forgetting a numerator, then calc stills evaluates it and gives a "incorrect" result as someone could meant to not have the 1 as a numerator.

@lcn2 lcn2 added the question label Jan 28, 2022
@lcn2
Copy link
Owner

lcn2 commented Jan 28, 2022

We are not use if this is a bug or a feature. :-)

We are also not sure that there might be code out there that assumes /2 would work.

Hummm .. have to think about this.

More comments and perhaps even a proposed patch as a pull request are welcome.

@lcn2
Copy link
Owner

lcn2 commented Jan 29, 2022

We guess this comes down to a "is it a bug or feature?" question, @Gusted.

If this is a "feature" of the calc parser, one might also suggest this might be a feature that one might not want to encourage people using. On the the other hand we cannot think of a harm that such a "feature" causes.

We might document the "/2" feature for now AND indicate that it should not be used as it might be disallowed in the future.

What do you think of that approach?

Alternately if "/2" is a bug, then the parser would need to carefully be modified to disallow it.

@Gusted
Copy link
Author

Gusted commented Jan 29, 2022

Hmm, I think it's a nice feature, but one that shouldn't exist really. I'd like the approach of documenting the /2 feature with the indication that it will be disallowed/removed in the future. Alternatively to raise some awareness to this, is it possible to log a "WARNING" that when this is used, that it shouldn't be used?

@lcn2 lcn2 self-assigned this Mar 6, 2023
@lcn2 lcn2 added enhancement and removed question labels Mar 6, 2023
@lcn2 lcn2 changed the title Numerator is assumed Enhancement: Document or warn when the numerator is assumed Mar 6, 2023
@lcn2
Copy link
Owner

lcn2 commented Oct 4, 2023

This issue will be addressed in calc v3: see issue #103. We are closing this issue do that any further discussion may occur in issue #103.

@lcn2 lcn2 closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants