On Mon, Jan 18, 2010 at 12:44 PM, Eldar Insafutdinov
<e.insafutdi...@gmail.com> wrote:
> Denis Koroskin Wrote:
>
>> You know, I'm not usually a guy who proposes radical changes to the
>> language. I like the way D is, but there are a few proposals that keep
>> popping up once in a while without a good rationale, and this simple idea
>> stroke my head solves many of the issues that were found in previous
>> proposals, so I decided to share it with you.
>>
>> It's as simple as that: require '*' to denote reference type. What does it
>> give?
>>
>> 1) Consistency between classes and structs:
>>
>> Struct* s = new Struct();
>> Class* c = new Class();
>>
>> It allows easier transition between classes and structs (please note that
>> I don't propose any changes to class semantics):
>> Foo* f = new Foo(); // works for both classes and structs
>>
>> 2) .sizeof consistency, get rid of __traits(classInstanceSize, Foo)
>> (deprecate in favor of Foo.sizeof):
>>
>> Foo* f = cast(Foo*)malloc(Foo.sizeof); // works for both classes and
>> structs (and enums, unions, etc)
>> f.__ctor(args);
>>
>> 3) No more issues with tail-const, tail-shared, tail-immutable; deprecate
>> Rebindable (this one was recently discussed):
>>
>> shared(Foo)* foo; // local pointer to shared type, works for both classes
>> and structs
>>
>> Please note that we get these bonuses by only enforcing '*' to denote
>> refence type, not a huge change to compiler IMO. It *will* break existing
>> code, but the fix is rather trivial.
>>
>> To be continued.
>
> I was recently thinking about it as well, but didn't dare to shout things 
> like this. Looks much better to me in terms of consistency. The generic code 
> would benefit from that certainly. I am all for it.
>
> D2 has changed a lot anyway. And it requires conversion as well. This is a 
> good time to make this kind of a radical change.

I'd say the chance of anything like this happening for D2 is
approximately zero to about six decimal places.  But it's interesting
to think about.

--bb

Reply via email to