All right, all right! Interim decision regarding qualified Object methods

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jul 12 11:50:53 PDT 2012


On Thu, Jul 12, 2012 at 01:51:31PM -0400, Andrei Alexandrescu wrote:
> On 7/12/12 1:40 PM, David Piepgrass wrote:
> >1. Most importantly, the C++ template approach is a big pain for
> >large-scale systems, [...]
> 
> The thing is, that can be done in an opt-in manner. People who want
> methods in the root of the hierarchy can define a root that defines
> them. But there's no way to opt out of inheriting Object. Basically
> it's nice to not force people to buy into a constrained environment
> without necessity.

Having a class RawObject as a superclass of Object is an equally good
solution. Declare a class without a base class, and the base class
defaults to Object.  Explicitly write "class MyClass : RawObject" and
you get a class without the stuff in Object. If you want an entire
hierarchy free of the stuff in Object, just write "class MyBaseClass :
RawObject" and inherit everything from it.

This has the advantage of _not_ breaking any existing code, and the
people who want to opt out of Object, can.


[...]
> >1. Provide a 'safe workaround' for const, for caching and lazy
> >evaluation (implement it carefully to avoid breaking the guarantees
> >of immutable)
> 
> We should explore this option in any case. At this point I'm
> starting to believe (a) we're doing the right thing by marginalizing
> the four methods aside from this issue, (b) caching is good for
> other things than this particular problem.
[...]

Please also remember that caching is only _one_ of the issues. Objects
that exist over the network is another use case. Objects that are
partially stored in (possibly remote) database. There are many other
such cases. I hope we don't neglect these other cases by focusing only
on caching.


T

-- 
Why are you blatanly misspelling "blatant"? -- Branden Robinson


More information about the Digitalmars-d mailing list