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

Removal of Natural #98

Closed
gavinking opened this issue Dec 10, 2011 · 6 comments
Closed

Removal of Natural #98

gavinking opened this issue Dec 10, 2011 · 6 comments

Comments

@gavinking
Copy link
Member

So we're considering removing the Natural class and using Integer for sequence indices. Subtractable would also be removed. See the discussion in this thread:

http://groups.google.com/group/ceylon-dev/browse_thread/thread/82daa1e0750f133a?hl=en

I've already done most of the work needed for this in branches of the ceylon/ceylon-spec and ceylon/ceylon.language projects. Tako is working on a branch of ceylon/ceylon-compiler (UPDATE: he finished that work). So we should be able to roll this change into M1.

But first I need to get the OK from everyone else here that this is the right thing to do, and that we should go ahead and merge the branches.

Feedback?

@davidfestal
Copy link
Member

I'malso Ok to drop it and replace by annotations or interceptors in the future.

@FroMage
Copy link
Member

FroMage commented Dec 11, 2011

I don't feel strongly either way. I like the concept of Natural, as an equivalent of C's unsigned int BUT the JVM won't let us get the positive limit we'd expect from it (since we are not using negative numbers), AND I'd much rather have an exception when a Natural goes below zero (like I wish we had when numbers go above/below their limit, instead of overflowing and setting an ignored bit in the CPU registers), but since the JVM doesn't throw on overflow, overflowing on negative values wouldn't be that bad. It's just that 0 is a lot closer to the common day usage than the positive/negative limits of long.

If I would keep it I would allow users to subtract Natural numbers and guard it with a check, so it'd be slower than other math ops but not that bad.

I wouldn't lose sleep over getting rid of Natural either.

@gavinking
Copy link
Member Author

Then in that case I'm inclined to go ahead with the removal of Natural. I still want to hear from Emmanuel. I already know Tako is in favor. Tom told me he likes Natural but says he doesn't care enough to argue strongly in favor of it. I personally think this change has great benefits for new users and for overall simplicity.

@emmanuelbernard
Copy link
Member

I have to admit my background in C is limited so I've never lived in a world of true unsigned integers. But from what the thread reads

  • there are plenty of drawbacks (at least as much as using Integers in lieu of Naturals)
  • the documentation purpose can be handled (not as completely) by an annotation
  • less is more :)

On a side note, should we have a positive annotation that can be used by the compiler as a hint at some stage. I'm tempted to say no unless we are ok to enforce that a positive Integer can only be filled by another positive Integer but that might require things like

if (is positive index) {
    //use it as positive integer
}

and that might be too cumbersome

@gavinking
Copy link
Member Author

Natural has been removed.

@FroMage
Copy link
Member

FroMage commented Dec 12, 2011

Long live Natural!

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

4 participants