I need some help here.

Reiner Pope reiner.pope at REMOVE.THIS.gmail.com
Thu Aug 31 16:02:55 PDT 2006

Damian wrote:
> I would have to use 
> MyArray!(MyArray!(char)) _data;
> for _data to be really immutable.
> Anyway, I can't do this that way, since my class "cl" couldnt modify
> _data either.

No, that's not quite what I meant. Your class (cl) would look like this:

class cl{
         char[][] _data;
         int _maxDataLength;
         MyArray!(MyArray!(char)) data() {
             // Construct a MyArray which represents a readonly view of 
the data

         int maxDataLength(){
             return _maxDataLength;
         int calculateMaxDataLength(char[][] data){
             // this takes time.

The constructor would be annoying to write, though, because you would 
need to recursively generate one for each level of the array. However, a 
bit of template magic could be your solution here, I think.

Yes, from your other post, const is really what you need, and many 
people find it lacking. However, it is way too complex to rush, and 
there has not yet been a perfect solution proposed. There probably never 
will be, so D may remain without const.



More information about the Digitalmars-d-learn mailing list