On Thu, Aug 8, 2013 at 5:05 PM, David Jeske <[email protected]> wrote:

>
>> A readonly generic list of mutable objects
>>
>
> Another method is to use const, and rely on the fact that methods which
> change the list require a non-const pointer, as in..
>
>   var alist = (const ICollection<Foo>)new List<Foo>();
>
>   alist.Add(aFoo);  // compiler error, because ICollection:Add() requires
> non-const "this"
>

This should have been...

  var alist = (shallow_const ICollection<Foo>)new List<Foo>();

where "shallow_const" means that the ICollection pointer itself is
"shallow_const", and thus can't be bound to any non-const "this" pointers
in methods, but all fields and method return values are normal mutable
non-const references.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to