Re: confused with some_var.dup

2009-01-17 Thread Christopher Wright
Rainer Deyke wrote: Christopher Wright wrote: You can create a COW array struct pretty easily. However, this will be pretty slow in a lot of cases. A built-in COW type does not need to be slow! The compiler can use static analysis to eliminate unnecessary copies, and reference counting can be

Re: confused with some_var.dup

2009-01-16 Thread Rainer Deyke
Christopher Wright wrote: > You can create a COW array struct pretty easily. However, this will be > pretty slow in a lot of cases. A built-in COW type does not need to be slow! The compiler can use static analysis to eliminate unnecessary copies, and reference counting can be used to further red

Re: confused with some_var.dup

2009-01-16 Thread Christopher Wright
Qian Xu wrote: Denis Koroskin wrote: The "Hello, World!" string is not allowed to be modified, because it could be shared throughot the project and will be most probably put in a read-only memory causing segfault at modification. But it you need to have a modified version of this this, you crea

Re: confused with some_var.dup

2009-01-16 Thread Denis Koroskin
On Fri, 16 Jan 2009 19:15:03 +0300, Qian Xu wrote: Denis Koroskin wrote: The "Hello, World!" string is not allowed to be modified, because it could be shared throughot the project and will be most probably put in a read-only memory causing segfault at modification. But it you need to have

Re: confused with some_var.dup

2009-01-16 Thread Qian Xu
Denis Koroskin wrote: > > The "Hello, World!" string is not allowed to be modified, because it could > be shared throughot the project and will be most probably put in a > read-only memory causing segfault at modification. > > But it you need to have a modified version of this this, you create it

Re: confused with some_var.dup

2009-01-16 Thread Denis Koroskin
On Fri, 16 Jan 2009 10:30:53 +0300, Qian Xu wrote: When shall I use some_var.dup and when not? Is there any guidlines? --Qiansua .dup is typical way to makes a copy of variable: char[] greetings = "Hello, World!".dup; You usually do this when you want to modify variable that you are not al

Re: confused with some_var.dup

2009-01-15 Thread Tim M
On Fri, 16 Jan 2009 20:30:53 +1300, Qian Xu wrote: When shall I use some_var.dup and when not? Is there any guidlines? --Qian Yeah when you want one to be different than the other. If the lvalue is a slice then there is no need though.

confused with some_var.dup

2009-01-15 Thread Qian Xu
When shall I use some_var.dup and when not? Is there any guidlines? --Qian