Re: ignorance: customizable immutables?
Shelby <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
See my ideas in the thread, "The cake’s problem, dotty design and the
approach to modularity.
<https://groups.google.com/forum/#!topic/scala-language/WcnHXjAJaKg>"
Throw away virtual inheritance and so you can have multiple orthogonal
interfaces implemented on the same data. Thus, the type of your List would
be List[A or ADifferent]. In my idea, the compiler would insure your
asCapitalA would automatically be invoked with the necessary boiler-plate
so that it calls the correct interface. The result type of your map would
be the intersection of types `A or ADifferent`.
Afaics, the point is we stop subsuming to Any and retain the composition in
the types in the new DOT (Dotty) calculus. This can eliminate the need to
use virtual inheritance, especially if the compiler can be made smart
enough to automatically handle all the boiler-plate for manual injection.
Btw, I was advocating for an intersection type for Scala since (circa 2011
afair) before I became aware of the DOT calculus. I filled up the Github
gist questionaire on what the semantics of the intersection type should be:
https://issues.scala-lang.org/browse/SUGGEST-22
Whoops, I realized I juxtaposed intersection and disjunction in my
messages.
On Wednesday, June 17, 2015 at 1:44:58 AM UTC+8, raould wrote:
>
> > List(new A, new A{ override def foo = "different" }).map(x.asCapitalA)
> > If `asCapitalA` has mutating side-effects, you retain the distinct `foo`
> > behavior. If, in contrast, it creates a new immutable A, your unique
> `foo`
> > behavior is lost.
>
> Are there any approaches people like to use to get immutables that
> respect whatever customization has been done -- some way to assemble
> components and then still be able to frob() them and get a new
> immutable copy that retains the customizations? Concisely, robustly? I
> mean in any programming language.
>
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.