<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 13.04.2018 23:16, Sven Barth via
      fpc-devel wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFMUeB-QQK+YTHLbH6peXf5EXKYfp3ZS=reCxe2URmyhh0Hy+A@mail.gmail.com">
      <div dir="auto">
        <div>
          <div class="gmail_quote">
            <div dir="ltr">Ondrej Pokorny <<a
                href="mailto:lazarus@kluug.net" moz-do-not-send="true">lazarus@kluug.net</a>>
              schrieb am Fr., 13. Apr. 2018, 21:16:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF">
                <div class="m_-2479975938792404394moz-cite-prefix">On
                  13.04.2018 14:08, Sven Barth via fpc-devel wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="auto">
                    <div>
                      <div class="gmail_quote">
                        <div dir="ltr">Ondrej Pokorny <<a
                            href="mailto:lazarus@kluug.net"
                            target="_blank" rel="noreferrer"
                            moz-do-not-send="true">lazarus@kluug.net</a>>
                          schrieb am Fr., 13. Apr. 2018, 12:52:<br>
                        </div>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div text="#000000" bgcolor="#FFFFFF">I
                            introduced the AS operator for enumerations
                            in <a
                              class="m_-2479975938792404394m_7860075233186958794moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=33603" rel="noreferrer
                              noreferrer" target="_blank"
                              moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=33603</a></div>
                        </blockquote>
                      </div>
                    </div>
                    <div dir="auto"><br>
                    </div>
                    <div dir="auto">What about enums with holes?</div>
                  </div>
                </blockquote>
                <br>
                No problem because Low() and High() work with these
                enums as well. See the test case project I attached to
                the bug report - it has a test with such an enum.<br>
              </div>
            </blockquote>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">I wasn't talking about the boundaries. I meant
          undefined values inside the enum. If we want such a cast
          operator to work with such enums as well it should check for
          invalid values inside the enum, too. Otherwise the operator
          isn't worth it and should be forbidden for such enums.</div>
      </div>
    </blockquote>
    <br>
    Sven (or anybody else), could you please comment on
    <a class="moz-txt-link-freetext" href="https://bugs.freepascal.org/view.php?id=33603">https://bugs.freepascal.org/view.php?id=33603</a> ? I feel I am getting
    crazy.<br>
    <br>
    From what I read, there seems to be a difference between FPC and
    Delphi understanding of "enums with holes":<br>
    <br>
    1.) FPC understands the holes as undefined values - docs:
    <a class="moz-txt-link-freetext" href="https://www.freepascal.org/docs-html/ref/refsu4.html#x26-280003.1.1">https://www.freepascal.org/docs-html/ref/refsu4.html#x26-280003.1.1</a>
    :<br>
    <br>
    <div class="verbatim" id="verbatim-37" style="font-family:
      monospace; white-space: nowrap; text-align: left; clear: both;
      color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures:
      normal; font-variant-caps: normal; font-weight: 400;
      letter-spacing: normal; orphans: 2; text-indent: 0px;
      text-transform: none; widows: 2; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; text-decoration-style: initial;
      text-decoration-color: initial;">Type  <br>
        EnumType = (one, two, three, forty := 40, thirty := 30);</div>
    <p class="nopar" style="text-indent: 0px; color: rgb(0, 0, 0);
      font-family: "Times New Roman"; font-size: medium;
      font-style: normal; font-variant-ligatures: normal;
      font-variant-caps: normal; font-weight: 400; letter-spacing:
      normal; orphans: 2; text-align: start; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; text-decoration-style: initial;
      text-decoration-color: initial;">It is necessary to keep<span> </span><span
        class="cmtt-10" style="font-family: monospace;">forty<span> </span></span>and<span> </span><span
        class="cmtt-10" style="font-family: monospace;">thirty<span> </span></span>in
      the correct order. When using enumeration types it is important to
      keep the following points in mind:</p>
    <ol class="enumerate1" style="list-style-type: decimal; color:
      rgb(0, 0, 0); font-family: "Times New Roman"; font-size:
      medium; font-style: normal; font-variant-ligatures: normal;
      font-variant-caps: normal; font-weight: 400; letter-spacing:
      normal; orphans: 2; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      text-decoration-style: initial; text-decoration-color: initial;">
      <li class="enumerate" id="x26-28003x1">The<span> </span><span
          class="cmtt-10" style="font-family: monospace;">Pred<span> </span></span>and<span> </span><span
          class="cmtt-10" style="font-family: monospace;">Succ<span> </span></span>functions
        cannot be used on this kind of enumeration types. Trying to do
        this anyhow will result in a compiler error.</li>
    </ol>
    <p>2.) Delphi understands the holes as well-defined values that only
      lack a name - docs:
<a class="moz-txt-link-freetext" href="http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Simple_Types_(Delphi)#Enumerated_Types_with_Explicitly_Assigned_Ordinality">http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Simple_Types_(Delphi)#Enumerated_Types_with_Explicitly_Assigned_Ordinality</a></p>
    <p>type Size = (Small = 5, Medium = 10, Large = Small + Medium);<br>
      <br>
      An enumerated type is, in effect, a subrange whose lowest and
      highest values correspond to the lowest and highest ordinalities
      of the constants in the declaration. In the previous example, the
      Size type has 11 possible values whose ordinalities range from 5
      to 15. (Hence the type array[Size] of Char represents an array of
      11 characters.) Only three of these values have names, but the
      others are accessible through typecasts and through routines such
      as Pred, Succ, Inc, and Dec.</p>
    <p>----<br>
    </p>
    <p>Also, the difference is demonstrated in the fact that Delphi and
      FPC delphi mode allow to define an array of Size. OBJFPC mode
      doesn't allow it.</p>
    <p>----</p>
    <p>Therefore I enabled the IS/AS operators on enums with holes only
      in Delphi mode and disabled them in all other modes.</p>
    <p>----</p>
    <p>Am I right in my understanding?</p>
    <p>Ondrej<br>
    </p>
  </body>
</html>