-
Notifications
You must be signed in to change notification settings - Fork 37
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
Allow to map bitfield fields into parent scope #1468
Comments
Without major rewrites any fix to this will likely only add syntactic sugar and incur the same runtime cost. |
Given that the manual approach requires ~3x the lines of code, the syntactic sugar would still be helpful I think. |
Mind elaborating why this would be so useful? Why is Background here is that Spicy actually only stores |
This is mostly for estethic reasons. In the use case this came up, the fields of the bitfield are defined as "first-class members", just like other fields of the protocol specification. Introducing the additional nesting (including meaningful naming) just feels a bit unnatural. Along those lines, I was also aiming to use the automatic export of types, which promises to save a lot of boilerplate code (now wondering whether bitfields are supported). So all in all, I am just trying to minimize work while coding closely along a protocol spec. |
Ok, got it. Yeah, your suggestion of not naming the bitfield would work well then I think. Like:
Then
Good question. :-) |
We should check what changes this needs for Zeek's Spicy integration. |
Re-assigning to me, I'm adding this to the other bitfield work. |
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468. TODO: - Add validation to catch ambigious access paths.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468. TODO: - Extend RTTI to make field's `isAnonymous()` available. - Add validation to catch ambigious access paths.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468. TODO: - Extend RTTI to make field's `isAnonymous()` available. - Add validation to catch ambigious access paths.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468.
This works now: type Foo = unit { : bitfield(8) { x: 0..3; y: 4..7; }; on %done { print self.x, self.y; } }; Closes #1468.
It would be nice if fields of a bitfield can be mapped in the parent scope:
For example, not naming the bitfield could make
x
andy
directly accessible fromFoo
.See Slack for a workaround at the cost of performance.
The text was updated successfully, but these errors were encountered: