Re: Question about enum values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Dillon

    Re: Question about enum values


    So, let's say, like what you said, we have this:

    0, 0000, None
    1, 0001, CanOpen
    2, 0010, CanProcess
    3, 0011, CanComplete
    8, 1000, CanCancel

    or

    0, 0000, None
    1, 0001, CanOpen
    2, 0010, CanProcess
    3, 0011, CanComplete
    4, 0100, CanCancel

    In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
    CanProcess gives us 0011

    In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
    | CanProcess gives us 0011

    Of course, in the second case, None | CanComplete and CanOpen |
    CanProcess will give us the same result: 0011
    >>You have 3 in your top example and is why it's failing. It's 4, not 3.

  • Author

    #2
    Re: Question about enum values

    On Sep 29, 12:41 pm, "Jeff Dillon" <jeffdil...@hot mailremove.com>
    wrote:
    So, let's say, like what you said, we have this:
    >
    0, 0000, None
    1, 0001, CanOpen
    2, 0010, CanProcess
    3, 0011, CanComplete
    8, 1000, CanCancel
    >
    or
    >
    0, 0000, None
    1, 0001, CanOpen
    2, 0010, CanProcess
    3, 0011, CanComplete
    4, 0100, CanCancel
    >
    In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
    CanProcess gives us 0011
    >
    In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
    | CanProcess gives us 0011
    >
    Of course, in the second case, None | CanComplete and CanOpen |
    CanProcess will give us the same result: 0011
    >
    >You have 3 in your top example and is why it's failing. It's 4, not 3.
    Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
    3) would work like Jeroen said.

    But, Jeroen says:

    <quote>
    If "CanComplet e" was defined as 3, it would look the same as CanOpen |
    CanProcess.
    </quote>

    So, I don't know if he wants CanCancel to be 4 or 8. That's why I had
    two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4. I did not need to test 0,
    1, 2, 4, 8, which I know how it works after Jeroen's explanation.



    Comment

    • Jeroen Mostert

      #3
      Re: Question about enum values

      Author wrote:
      On Sep 29, 12:41 pm, "Jeff Dillon" <jeffdil...@hot mailremove.com>
      wrote:
      >So, let's say, like what you said, we have this:
      >>
      >0, 0000, None
      >1, 0001, CanOpen
      >2, 0010, CanProcess
      >3, 0011, CanComplete
      >8, 1000, CanCancel
      >>
      >or
      >>
      >0, 0000, None
      >1, 0001, CanOpen
      >2, 0010, CanProcess
      >3, 0011, CanComplete
      >4, 0100, CanCancel
      >>
      >In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
      >CanProcess gives us 0011
      >>
      >In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
      >| CanProcess gives us 0011
      >>
      >Of course, in the second case, None | CanComplete and CanOpen |
      >CanProcess will give us the same result: 0011
      >>
      >
      >>You have 3 in your top example and is why it's failing. It's 4, not 3.
      >
      Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
      3) would work like Jeroen said.
      >
      But, Jeroen says:
      >
      <quote>
      If "CanComplet e" was defined as 3, it would look the same as CanOpen |
      CanProcess.
      </quote>
      >
      So, I don't know if he wants CanCancel to be 4 or 8.
      I... really don't want it to be anything. Pretend it doesn't exist. It's
      orthogonal to my point. If the flags are already incorrect it doesn't matter
      how you continue.
      That's why I had
      two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4. I did not need to test 0,
      1, 2, 4, 8, which I know how it works after Jeroen's explanation.
      >
      Yes, let's focus on that and forget the rest. 0, 1, 2, 4, 8 etcetera is the
      only correct progression for bitflags.

      --
      J.

      Comment

      • Author

        #4
        Re: Question about enum values

        On Sep 29, 12:57 pm, Jeroen Mostert <jmost...@xs4al l.nlwrote:
        Author wrote:
        On Sep 29, 12:41 pm, "Jeff Dillon" <jeffdil...@hot mailremove.com>
        wrote:
        So, let's say, like what you said, we have this:
        >
        0, 0000, None
        1, 0001, CanOpen
        2, 0010, CanProcess
        3, 0011, CanComplete
        8, 1000, CanCancel
        >
        or
        >
        0, 0000, None
        1, 0001, CanOpen
        2, 0010, CanProcess
        3, 0011, CanComplete
        4, 0100, CanCancel
        >
        In the first case, CanComplete | CanCancel gives us 1011 and CanOpen |
        CanProcess gives us 0011
        >
        In the second case, CanComplete | CanCancel gives us 0111, and CanOpen
        | CanProcess gives us 0011
        >
        Of course, in the second case, None | CanComplete and CanOpen |
        CanProcess will give us the same result: 0011
        >
        >You have 3 in your top example and is why it's failing. It's 4, not 3..
        >
        Yeah, I know Scott Allen's original (i.e., CanComplete = 4 instead of
        3) would work like Jeroen said.
        >
        But, Jeroen says:
        >
        <quote>
        If "CanComplet e" was defined as 3, it would look the same as CanOpen |
        CanProcess.
        </quote>
        >
        So, I don't know if he wants CanCancel to be 4 or 8.
        >
        I... really don't want it to be anything. Pretend it doesn't exist. It's
        orthogonal to my point. If the flags are already incorrect it doesn't matter
        how you continue.
        >
        That's why I had
        two cases, 0, 1, 2, 3, 8 and 0, 1, 2, 3, 4.  I did not need to test 0,
        1, 2, 4, 8, which I know how it works after Jeroen's explanation.
        >
        Yes, let's focus on that and forget the rest. 0, 1, 2, 4, 8 etcetera is the
        only correct progression for bitflags.
        >
        --
        J.
        I understood, I was only testing how we get

        OrderTransition s canCompleteAndC ancel = OrderTransition s.CanComplete |
        OrderTransition s.CanCancel;

        should we assign 0, 1, 2, 3, 4 or 0, 1, 2, 3, 8.

        I guess it is my turn to confuse you now. :-)


        Comment

        • Peter Webb

          #5
          Re: Question about enum values

          I... really don't want it to be anything. Pretend it doesn't exist. It's
          orthogonal to my point. If the flags are already incorrect it doesn't
          matter how you continue.
          >
          I would have thought that the underlying vectors being orthogonal was your
          point !


          Comment

          Working...