-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Proposal for bit data (Ver 2) #327
Conversation
manipulations to a satisfactory level. We support a macro `bitflags!` for | ||
supporting individual bits, but there is no support for bit-ranges. Anyone | ||
who has had to write disassemblers for the x86 instruction set would concur | ||
to how error-prone it is to deal with shifts and masks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/to //
Is there a need to add keywords and syntax to Rust instead of building on top of the existing syntax? |
@eddyb This was discussed before, but the short version is that no - a syntax extension is not possible. What people have done instead is to run their own parser/external tool to just do the job, and that is not quite where you want to be (if you are supposed to be a systems language). |
@engstad I'm not sure I see why a syntax extension would not be possible here. Why can the error checking not be done in a syntax extension? Likewise, what prevents a type defined by a We've implemented similar functionality to that proposed here in the Zinc project. This involved a syntax extension and while we only handle the single constructor case (and adopt a rather different syntax than typical Rust) I believe this approach could be easily adapted. |
For the record, the first iteration of this RFC was #205. |
Wouldn't it be better enhance enum and struct than add a new type of data (and keyword). odd-sized numerical types and mod types (like Ada) are fairly similar and could probably be implemented together.
|
@bgamari Yes, I checked the ioregs!() functionality. While it is an impressive syntax extension, it still doesn't cover @Ericson2314 I think it is quite important to differentiate bit-data and byte-data, simply because with bit-data you don't have to consider alignment and endianess. Having said that, yes our bitdata StreamInfo {
SI {
num_elements: u12,
stream_index: u4,
stride: u8,
format: u8,
typ: u8,
offset: u8,
size: u8,
flags: u8
}
}
struct Mesh {
num_indexes : u32,
num_streams: u32,
total_stream_size: u32,
#[align(16)] indexes: [u16, ..num_indexes],
#[align(16)] stream_info: [StreamInfo, ..num_streams],
#[align(16)] stream_data: [u8, ..total_stream_size]
} |
engstad [email protected] writes:
I believe there was some resistance in the past to allowing arbitrary As far as accessors goes, I agree that they are a bit onerous in the |
Any proposal for bit data should have more details about the low-level representation of the bit data in memory, as it is important that the layout matches specific formats that are defined outside of Rust code. In this today's triage meeting we decided to postpone this RFC. I opened a tracking issue as #346. |
UnboundedSender::send does not need to accept mut self
After having addressed most of the issues, here's the updated RFC.