[Dlang-study] [lifetime] Initial thoughts on lifetime management

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Oct 28 03:52:52 PDT 2015


On 28-Oct-2015 13:34, Jonathan M Davis wrote:
> On Tuesday, October 27, 2015 20:45:00 Andrei Alexandrescu wrote:
>> * do not inherit Object. (Do we want a root of all @rc classes called
>> RCObject?)
> Honestly, I think that having Object was a mistake. We already decided
> previously that we wanted to remove pretty much all of the functions from
> Object in order to fix the problem with have with forcing specific
> attributes on functions like toString or opEquals (though unfortunately, we
> haven't gotten very far with actually implementing such changes). And if we
> do that, Object becomes borderline useless. Also, because we have proper
> templates rather than Java-style generics, we've eliminated what's probably
> the primary use case for having an Object reference rather than the
> reference of the actual type of the object (or one of its base classes whose
> API actually gets used as opposed to just storing it as a reference toa base
> type).
>
>

Cutting to the chase - there is big reason for even nominal super type - 
(manual) type erasure.
Simply put - Queue!T where T is a class is trivially implemented as 
Queue!Object, same for most containers.
Some might need ordering or hashing, these are easily added as 
interfaces Hashable and/or Comparable. Now we might argue that 
containers must be templates, but code bloat in case of objects is HUGE 
and unjustified.

Even if there is nothing special to Object, there must be a way to 
express reference to any class instance in the language, let us not lose 
that.

-- 
Dmitry Olshansky


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3707 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.puremagic.com/pipermail/dlang-study/attachments/20151028/c894705f/attachment.bin>


More information about the Dlang-study mailing list