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

generalize a bunch of boiler-plate type code for creating integers #4737

Closed
wants to merge 1 commit into from

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 6, 2013

This generalizes a lot of code in int.jl, with the goal of making it easier to create new bitstypes. While I realize immutable types have rather stolen the show, bitstypes are sometimes still nice. This reduces the number of boilerplate methods necessary to create a minimal bits type by 24!

@JeffBezanson @StefanKarpinski @ViralBShah OK to merge?

I'm also thinking of adding some generic convert, promote_rule, and arithmetic functions so that you can just call bitstype <: Signed (or Unsigned) and everything would pretty much just work.

@StefanKarpinski
Copy link
Member

Absolutely do not merge anything like this before 0.2!

@JeffBezanson
Copy link
Member

I'm all for thinking about how we could make something like this work, but right now it doesn't without deeper changes. As has been pointed out, the problem is that box/unbox only apply to bitstypes. See also issue #1470

@vtjnash
Copy link
Member Author

vtjnash commented Nov 6, 2013

I could make a macro which does the 'basics' of making a new numerical type. What we really want here is:
f{I<:Integer::Bitstype}(x::I) = ...
Or
f{I<:Integer}(x::I::Bitstype) = ...
I think there's already an open issue for considering something like this?

@simonbyrne
Copy link
Contributor

A simpler option might be to define a new abstract subtype of Integer, say BitsInteger?

@vtjnash vtjnash deleted the jn/shortint branch August 27, 2015 04:16
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.

5 participants