DMD 2.000 alpha release

eao197 eao197 at intervale.ru
Wed Jun 20 11:03:49 PDT 2007


On Wed, 20 Jun 2007 17:39:43 +0400, Chris Nicholson-Sauls  
<ibisbasenji at gmail.com> wrote:

>>> This is going to save me plenty of memory costs (imagine, no longer  
>>> .dup'ing lots of strings and other arrays just to play it safe against  
>>> silly end users modifying what they shouldn't) not to mention  
>>> debugging headaches.
>>  How do you plain to reduce count of .dup's in D 2.0?
>>
>
> By returning const views rather than copies.  Or in some cases,  
> referances to invariant data.

Do you mean something like:

class Demo
   {
     this( const char * name )
       {
         name_ = name.dup;
       }

     const char *
     getName() { return name_; }

   private:
     char[] name_;
   }

instead of

   char[]
   getName() { return name_.dup; }

?

-- 
Regards,
Yauheni Akhotnikau



More information about the Digitalmars-d-announce mailing list