Re: Reuse of variables referencing const objects

2009-03-10 Thread Steven Schveighoffer
On Mon, 09 Mar 2009 23:00:50 -0400, Chris Nicholson-Sauls wrote: Sergey Kovrov wrote: On 3/9/2009 8:50 PM, Chris Nicholson-Sauls wrote: While not strictly intuitive, you could do this: auto var = Rebindable!(const Foo)(new Foo); assert(var.opDot !is null); As 'opDot' returns the wrapped objec

Re: Reuse of variables referencing const objects

2009-03-09 Thread Chris Nicholson-Sauls
Sergey Kovrov wrote: On 3/9/2009 8:50 PM, Chris Nicholson-Sauls wrote: While not strictly intuitive, you could do this: auto var = Rebindable!(const Foo)(new Foo); assert(var.opDot !is null); As 'opDot' returns the wrapped object (with const intact). The downside to that, however, is that it wo

Re: Reuse of variables referencing const objects

2009-03-09 Thread Sergey Kovrov
On 3/9/2009 8:50 PM, Chris Nicholson-Sauls wrote: While not strictly intuitive, you could do this: auto var = Rebindable!(const Foo)(new Foo); assert(var.opDot !is null); As 'opDot' returns the wrapped object (with const intact). The downside to that, however, is that it won't work in those case

Re: Reuse of variables referencing const objects

2009-03-09 Thread Chris Nicholson-Sauls
Sergey Kovrov wrote: On 3/6/2009 11:29 PM, Steven Schveighoffer wrote: std.typecons.Rebindable http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#Rebindable Thanks Steve, this is what I've been looking for, the only thing missing is comparing against null (is null). -- serg. Whi

Re: Reuse of variables referencing const objects

2009-03-07 Thread Sergey Kovrov
On 3/6/2009 11:29 PM, Steven Schveighoffer wrote: std.typecons.Rebindable http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#Rebindable Thanks Steve, this is what I've been looking for, the only thing missing is comparing against null (is null). -- serg.

Re: Reuse of variables referencing const objects

2009-03-06 Thread bearophile
Sergey Kovrov: > I guess there is a data member for allocated buffer size as well... Nope, this isn't vector of C++. It's a long story (caused to allow the slicing). The result is that the append is very slow. > Objects may be viewed as a structure too. There are context pointer > virtual func

Re: Reuse of variables referencing const objects

2009-03-06 Thread Steven Schveighoffer
On Fri, 06 Mar 2009 09:39:43 -0500, Sergey Kovrov wrote: > Other reference types (e.g. arrays) have solution to this: > ``immutable(TYPE)[]`` and ``immutable(TYPE[])`. > > I think class instances should have something similar in language as > well. > > > -- serg. std.typecons.Rebindable http:

Re: Reuse of variables referencing const objects

2009-03-06 Thread Sergey Kovrov
On 3/6/2009 4:42 PM, bearophile wrote: Arrays aren't really references, they are a small 2-word long struct, that contains a pointer to the data and a length. I guess there is a data member for allocated buffer size as well... Objects may be viewed as a structure too. There are context pointer

Re: Reuse of variables referencing const objects

2009-03-06 Thread bearophile
Sergey Kovrov: > Other reference types (e.g. arrays)< Arrays aren't really references, they are a small 2-word long struct, that contains a pointer to the data and a length. Bye, bearophile

Re: Reuse of variables referencing const objects

2009-03-06 Thread Sergey Kovrov
Other reference types (e.g. arrays) have solution to this: ``immutable(TYPE)[]`` and ``immutable(TYPE[])`. I think class instances should have something similar in language as well. -- serg.