scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
401 stars 67 forks source link

Tighten up token length rules. #306

Closed scott-griffiths closed 2 months ago

scott-griffiths commented 7 months ago

Currently string tokens take the form name[:]length=value, and there is a general rule that the optional : isn't used unless it looks unclear without it. It generally will only look unclear if the length value is non-numeric.

As we move towards having user types it will become impossible to keep this rule. For example bitstart could be a bits token of length tart or a new user defined bitstart token with no length given (or several other options). It seems reasonable to require it to be written as bits:tart if that was the intent.

For numeric lengths I like the rule that type names cannot end in an integer. This could be a bit annoying but the benefits are fairly obvious.

Slightly backwards incompatible.

scott-griffiths commented 2 months ago

This change has already gone in as part of version 4.2.