-
Notifications
You must be signed in to change notification settings - Fork 0
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
packed object / bitfields #741
Comments
Hows this different from a set of enum ?, or is it the metaprogramming part that has the magic ?. 🤔 |
a packed object is intended to replace simple objects in cases like this: type Bar = enum b0, b1, b2, b3
type A0 = object
switch: bool
val: range[10..12]
bar: Bar
type A1 = Packed(switch: bool, val: 10..12, bar: Bar)
assert A0.sizeof == 24
assert A1.sizeof == 4 beside the large saving (and likely more efficient operations), you get syntax sugar like
|
So like an object implemented on top of a set ?, all attributes must be ordinal right ?, sounds interesting... 🤔 |
correct, you can't have these types as fields: you can have these: that's the restriction |
Write the RFC. Offtopic: I wish stdlib had a fixed point. |
TODO: write proper RFC
proposal
add
Packed
, which generalizes builtinset
by packing several set into 1 bit sequence, allowing one to represent objects compactly as a single bit sequence (eg equivalent to an int)Example
links
The text was updated successfully, but these errors were encountered: