Phobos

James Dunne james.jdunne at gmail.com
Thu Mar 9 07:30:06 PST 2006


Georg Wrede wrote:
> Ben Phillips wrote:
> 
>> In article <dune2o$cu4$1 at digitaldaemon.com>, Def says...
>>
>>> Array op= operations are not implemented.
>>
>>
>> This has been discussed numerous times and the consensus is that
>> overloading "=" is a bad idea. You must remember that D uses
>> references so if we have a class and two instances ("a" and "b") then
>> "a = b;" makes "a" refer to the same object as "b". The programmer
>> should not be allowed to change this behavior.
>>
>> On the other hand, another operator such as ":=" has been suggested
>> which would be a copy operator rather than an assignment operator
> 
> 
> It would definitely stand out in code better than a .dup swamped 
> somewhere inconspicuous.

But you lose all meaning as to if that dup is a shallow copy or deep copy.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------

James Dunne



More information about the Digitalmars-d mailing list