Code Monkey home page Code Monkey logo

Comments (2)

Robbepop avatar Robbepop commented on July 17, 2024

To simplify the overall design of this crate we should actually replace the current #[bitfield(filled: bool)] parameter with the proposed #[bitfield(bits = N)] parameter.

They way bits = N could replace filled: bool is wherever filled = false has to be used right now we would enforce usage of bits = N with N being the bits that the user wants the bitfield to have. With #[skip] __: BN users can easily define whole areas of a bitfield to leave as undefined which should be used instead of using filled = false and is more powerful than that.

This also unifies design of the #[derive(BitfieldSpecifier)] derive macro for enums.

from modular-bitfield.

Robbepop avatar Robbepop commented on July 17, 2024

I have made some more thoughts about this and came to the conclusion that with the introduction of a bits: int parameter we no longer really want or need the bytes: int parameter with which we (so far) controlled the amount of bytes that a bitfield is going to need. So introducing the bits: int should deprecate or remove the bytes: int parameter which makes the overall design a bit simpler because you no longer need to handle cases like bits = 32, bytes = 3 that are conflicting with each other.

What I wrote above about filled: bool parameter might not be true entirely. There are two stand points:

  1. Keeping filled: bool and allowing interactions using both configs.

    • bits = N, filled = true: The bitfield must not have undefined bits and must have a bit width of exactly N.
    • bits = N, filled = false: The bitfield may have undefined bits and defaults to bit width equal to N. It is asserted at compile time that the required bits do not exceed or equal N - aka it is asserted that there are undefined bits.
  2. Removing of the filled: bool parameter:

    • How exactly can be differentiate between the 2 above cases with filled = false and filled = true?
      Do we actually really need filled = false? We just introduced #[skip] __: BN for pretty much the same purpose.
      The only advantage of filled = false is that it is a tad less to write and does not require yet another "fill" field.
      This comes more in handy if the bitfield is generally very small, e.g. contains just 1 or 2 bit fields.

from modular-bitfield.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.