Request: Implement constant folding for .dup

Don Clugston dac at nospam.com.au
Tue Feb 20 08:53:57 PST 2007


Stewart Gordon wrote:
> Don Clugston Wrote:
>> Since COW is used so much in D, especially with strings, allowing 
>> "abc".dup to be constant-folded would greatly increase the amount 
>> of existing code which could be used at compile-time.
> 
> What would the semantics be exactly?

Just create a new const with the same value as the first one -- all 
compile-time consts have value semantics.

ie,
char [] a = "xyz";
char [] b = a.dup;

would be the same as
char [] a = "xyz";
char [] b = "xyz";



More information about the Digitalmars-d mailing list