Whoops, I accidentally sent this to Peter instead of the whole list... This doesn't even need to be a very hard feature to implement, or require any new syntax. All that needs to happen is for the compiler to know that "& 0b11" means the only viable options are 00, 01, 10, and 11. True?
val[6..7] type syntax would be really cool, and definitely would set rust apart, but so many people are already comfortable with writing bitfields as shifts and masks that we probably want to support that use case well first, and then look at extending it. On Fri, Mar 28, 2014 at 9:55 AM, Evan G <[email protected]> wrote: > This doesn't even need to be a very hard feature to implement, or require > any new syntax. All that needs to happen is for the compiler to know that "& > 0b11" means the only viable options are 00, 01, 10, and 11. True? > > val[6..7] type syntax would be really cool, and def set rust apart, but so > many people are already comfortable with writing bitfields as shifts and > masks that we probably want to support that use case well first, and then > look at extending it. > > > On Fri, Mar 28, 2014 at 9:43 AM, Peter Marheine <[email protected]>wrote: > >> On Fri, Mar 28, 2014 at 9:30 AM, Jared Forsyth <[email protected]> >> wrote: >> > Is rust's macro system powerful enough to do calculations, such that you >> > would be able to guarantee that the provided patterns were exhaustive? >> > From what I've seen, the macro system can mostly just do syntax >> expansion - >> > not logic, etc. >> >> I haven't had occasion to work with the macro system at all, but it >> looks like you're correct now that I've reviewed the docs further. >> >> Reimplementing exhaustiveness checking in custom code is an ugly idea >> to me in itself. It looks like the requirement here is actually that >> the compiler must allow us to represent arbitrary-width integers. With >> that, we get exhaustiveness checking on bitfields for "free", and the >> only question is bikeshedding exactly how a user may go about >> extracting a bitfield. >> _______________________________________________ >> Rust-dev mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/rust-dev >> > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
