Add bitwise Integer operations
- Status
- Fixed
- Fixed in
- v26.6.8
- Source discussion
- https://forum.objo.dev/d/458-enumerations-and-files
- Last updated
- 2026-06-30
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
Objo should add first-class bitwise operations for Integer values.
Today Objo has logical And, Or, Xor, and Not, but no bitwise integer operations. This makes common tasks awkward or impossible without custom arithmetic, including working with option masks, permissions, binary file formats, network/protocol flags, packed values, and flags-style enum patterns.
The first version should provide an explicit, readable API for integer bit manipulation without changing the existing logical meaning of And, Or, Xor, or Not.
Expected user-facing capabilities:
- Combine flags:
value.BitOr(other) - Test flags:
value.BitAnd(mask) <> 0 - Toggle flags:
value.BitXor(mask) - Clear flags:
value.BitAnd(mask.BitNot()) - Shift bits left and right for masks and packed binary data
- Use the operations with integer-backed enum values by explicitly converting enum members to
Integer
A likely initial API on Integer:
Function BitAnd(other As Integer) As Integer
Function BitOr(other As Integer) As Integer
Function BitXor(other As Integer) As Integer
Function BitNot() As Integer
Function ShiftLeft(count As Integer) As Integer
Function ShiftRight(count As Integer) As Integer
Example:
Enum StringSplitOptions
None = 0
RemoveEmptyEntries = 1
TrimEntries = 2
End Enum
Var options As Integer = Integer(StringSplitOptions.RemoveEmptyEntries).BitOr(Integer(StringSplitOptions.TrimEntries))
If options.BitAnd(Integer(StringSplitOptions.TrimEntries)) <> 0 Then
Print("Trim entries")
End If
This issue is only for bitwise integer operation support. A dedicated flags-enum feature can build on this later, but should be tracked separately.