valhalla-dev Digest, Vol 17, Issue 3
vitalyd at gmail.com
Sat Dec 19 06:23:21 UTC 2015
On Saturday, December 19, 2015, Thomas W <twhitmore.nz at gmail.com> wrote:
> Thanks Vitaly.
> If Optional<T> is the goal, perhaps the question might be to inline/
> specialize the storage of monadic/ "wrapper types" generally?
I don't see why types/wrappers over one other type are special. Optional
is special in that when it abstracts over a ref type the semantic of the
type can be fulfilled naturally by virtue of ref types already having an
absence value: null. The main point is you can exploit type info when it's
provided. That's kind of the point of specialization.
> There are probably a range of monadic/ wrapper types having one "major
> field" and decorated it with simple behavior. However relying on handcoding
> magic specializations in ArrayList, will restrict it to applying to
> Optional only.
> An alternative way of looking at this is to to designate Optional as
> "inline value" which then would enable a _generalized system_ to
> arbitrarily reorganize its storage and store/materialize it as necessary.
> While stored it would not be in standard representation and inlined
> accessors would be adapted to the inline storage representation.
> > The biggest advantage to doing this via specialization is that if you do
> come up with a better way to represent a generic type
> > with a given type arg, the user of such instantiations doesn't need to
> change their code.
> I was going to call you on this before -- claiming "flexibility" by having
> a very limited number of types specially coded for JDK Collections -- with
> the requirement for M * N custom code sections, M being the # of collection
> implementations and N being the number of types you specially support -- is
> not really very flexible.
> You're trading off the need for use-site awareness, for the need for
> collection-implementation awareness :)
How is this different from creating named types for all those
specializations? It's always preferable to put more burden on lib author
than its users, when given the choice.
Sent from my phone
More information about the valhalla-dev