<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>In addition to what Per says, you might also consider modelling
      your "large list of resources" as a lazy list? While you still
      have the problem of mapping enum values to ordinals, you would at
      least retain the list-like nature of the bag of constants.</p>
    <p>Maurizio<br>
    </p>
    <div class="moz-cite-prefix">On 20/08/2023 00:36, David Alayachew
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAA9v-_PH2tWye3tCuboPe-QctAK4C099EtCeiZjYXA2fda2ANw@mail.gmail.com">
      
      <div dir="ltr">
        <div class="gmail_default" style="font-family:monospace">Hello
          Leyden Dev Team,</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">I am
          very excited for the ComputedConstant JEP that has been
          recently announced. There are lots of places in my current
          projects that could use a feature like this.</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">Today,
          for example, I want to lazy load a gigantic list of resources
          (>100). However, these resources are not fetched via an
          index, they are fetched via a key.</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">My
          current data type that I am storing them into is essentially a
          Map<MyEnum, LargeList<MyResource>>. I would like
          to be able to swap out this map for a ComputedConstant that
          can give me my LargeList<MyResource> when I provide it
          an instance of MyEnum.<br>
        </div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">I could
          technically create a mapper that takes in MyEnum, turns it
          into its ordinal, and then does something like this.</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">ComputedConstant</div>
        <div class="gmail_default" style="font-family:monospace">    .of</div>
        <div class="gmail_default" style="font-family:monospace">    (</div>
        <div class="gmail_default" style="font-family:monospace">       
          MyEnum.values().length,</div>
        <div class="gmail_default" style="font-family:monospace">       
          i -> fetchLargeListOfMyResource(MyEnum.values()[i])<br>
        </div>
        <div class="gmail_default" style="font-family:monospace">    )</div>
        <div class="gmail_default" style="font-family:monospace">    ;</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">But I'd
          like to avoid that if at all possible. It feels like I would
          end up right back into that error-prone territory from before.</div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">Is this
          feature possible and worth doing as part of this JEP?<br>
        </div>
        <div class="gmail_default" style="font-family:monospace"><br>
        </div>
        <div class="gmail_default" style="font-family:monospace">Thank
          you for your time and help!</div>
        <div class="gmail_default" style="font-family:monospace">David
          Alayachew<br>
        </div>
      </div>
    </blockquote>
  </body>
</html>