Re: StableValue vs Optional

2025-06-17 Thread Maurizio Cimadamore
On 17/06/2025 16:01, Mickael Istria wrote: On Tue, Jun 17, 2025 at 4:51 PM Maurizio Cimadamore wrote: Maybe I'm misunderstanding... what would be the difference between StableValue::supplier and Supplier::cache ? Is it a discoverability issue you are pointing out (e.g. this

Re: StableValue vs Optional

2025-06-17 Thread Mickael Istria
On Tue, Jun 17, 2025 at 4:51 PM Maurizio Cimadamore < maurizio.cimadam...@oracle.com> wrote: > Maybe I'm misunderstanding... what would be the difference between > StableValue::supplier and Supplier::cache ? > > Is it a discoverability issue you are pointing out (e.g. this factory > would be more

Re: StableValue vs Optional

2025-06-17 Thread Maurizio Cimadamore
On 17/06/2025 15:25, Mickael Istria wrote: (and still believe a Supplier.cache(Supplier computer) would be a nice addition). Maybe I'm misunderstanding... what would be the difference between StableValue::supplier and Supplier::cache ? Is it a discoverability issue you are pointing out (e.g

Re: StableValue vs Optional

2025-06-17 Thread Mickael Istria
On Tue, Jun 17, 2025 at 3:34 PM Maurizio Cimadamore < maurizio.cimadam...@oracle.com> wrote: > Note that this is already part of the StableValue API: > https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/lang/StableValue.html#supplier(java.util.function.Supplier) > Yes, that

Re: StableValue vs Optional

2025-06-17 Thread Maurizio Cimadamore
On 17/06/2025 13:55, Mickael Istria wrote: Thanks for your answer. > the most minimalistic type to model that would be a Supplier. Indeed. I mentioned Optional, but as the discussion goes, what could work instead of an Optional would be a constructor `Supplier.cache(Supplier computer)` that

Re: StableValue vs Optional

2025-06-17 Thread Mickael Istria
Thanks for your answer. > the most minimalistic type to model that would be a Supplier. Indeed. I mentioned Optional, but as the discussion goes, what could work instead of an Optional would be a constructor `Supplier.cache(Supplier computer)` that would cache the computed value. That would be ev

Re: StableValue vs Optional

2025-06-17 Thread Maurizio Cimadamore
Hi Mickael, I think at a very high level, a stable value is just a supplier of some value, lazily computed. So, the most minimalistic type to model that would be a Supplier. In fact, this is what the StableValue provides as well (StableValue has a factory that takes a supplier and gives you ba

StableValue vs Optional

2025-06-17 Thread Mickael Istria
Hi all, (I'm new around here, so please excuse me for this late comment or in case this was already discussed in some place I missed; I have seached Jira and the mailing-list via search engine unsuccessfully). I just discovered the StableValue proposal of JEP-502, that's a preview feature for Jav