On Thu, 3 Apr 2025 11:23:36 GMT, Per Minborg <pminb...@openjdk.org> wrote:

>> Yes - but they cache different things -- the first caches results for values 
>> 0-9 -- the second cached results for 1, 2, 4, 8, 16, 32.
>
> That was intentional as the list is always `0..size` whereas a map can use 
> arbitrary inputs. Is there a better way to illustrate this than what we have 
> now?

I guess my "beef" is that the examples for int function and function are 
similar -- they use same class name. Reader might expect (as I did) that they 
do the same thing, just using a different backing storage. But they don't -- 
not only is the implementation tweaked to use function instead of int function 
-- also what is cached changes subtly. I'm afraid this will be difficult to 
follow for readers. If you want to highlight that the "function" example has 
more freedom, I think we'd be better off with using another example. For 
instance:

* use square(int)->int to show off int function/list
* use square_root(int)->int to show off function/map

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2026872636

Reply via email to