new principle of division between structures and classes

Weed resume755 at mail.ru
Sat Jan 10 14:48:03 PST 2009


Christopher Wright пишет:
> Weed wrote:
>> Denis Koroskin пишет:
>>
>>> I'd suggest you to state you ideas as simple and keep your posts as
>>> small as possible (trust me, few people like reading long posts).
>>
>> The extra-short formulation of my idea:
>> Objects should be divided on POD (struct) and non-POD (class).
>>
>> Instead of such division as now: POD && value type (struct) and POD &&
>> reference type (class).
> 
> The reference versus value type difference is just a matter of defaults.
> 
> Returning a class instance on the stack from a function is possible with
> inout parameters, though you can't use a constructor in that case:
> 
> void main ()
> {
>     scope MyClass obj = new MyClass;
>     foo (obj);
> }
> 
> void foo (inout MyClass obj)
> {
>     // initialize obj somehow
> }

Problem not only with constructor calling.
This way does not works for temporary objects. For example, at operator
overloading in expression like a = b + c + d.
The case in detail was considered in this thread:
"division of objects into classes and structures is bad",
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=81359

Also, it impossible to create an array of scope objects.



More information about the Digitalmars-d mailing list