RunArray immutable?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

RunArray immutable?

Damien Cassou-3
Hi,

While writing tests for RunArray, I have tried this:

array := RunArray new: 5 withAll: 2.
array at: 3 put: 5.

However, the second line generated an error: "Instances of RunArray are not indexable". I don't see why, conceptually speaking, RunArray would be immutable. They should behave just like arrays in my opinion.

Do you want to try to write #at:put: ?

-- 
Damien Cassou





Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Lukas Renggli
> array := RunArray new: 5 withAll: 2.
> array at: 3 put: 5.
>
> However, the second line generated an error: "Instances of RunArray are not
> indexable". I don't see why, conceptually speaking, RunArray would be
> immutable. They should behave just like arrays in my opinion.
>
> Do you want to try to write #at:put: ?

Have a look at TextAndTextStreamTest. I think this is what the
RunArray is supposed to do (as opposed to what a generic collection
should be able to do).

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Damien Cassou-3

On Feb 12, 2007, at 10:15 AM, Lukas Renggli wrote:

array := RunArray new: 5 withAll: 2.
array at: 3 put: 5.

However, the second line generated an error: "Instances of RunArray are not
indexable". I don't see why, conceptually speaking, RunArray would be
immutable. They should behave just like arrays in my opinion.

Do you want to try to write #at:put: ?

Have a look at TextAndTextStreamTest. I think this is what the
RunArray is supposed to do (as opposed to what a generic collection
should be able to do).

I don't understand what you are talking about. Do you agree with the addition of #at:put: or do you think RunArrays should not be modified ?

-- 
Damien Cassou





Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Lukas Renggli
> Have a look at TextAndTextStreamTest. I think this is what the
> RunArray is supposed to do (as opposed to what a generic collection
> should be able to do).
>
> I don't understand what you are talking about. Do you agree with the
> addition of #at:put: or do you think RunArrays should not be modified ?

I don't think that makes sense. RunArrays are mainly used to annotate
strings with text formats. It is not really a type of collection that
one should use in your own project. Have a look at
TextAndTextStreamTest, this class already includes a few tests for
RunArray and its intended use.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Damien Cassou-3

On Feb 12, 2007, at 10:35 AM, Lukas Renggli wrote:

Have a look at TextAndTextStreamTest. I think this is what the
RunArray is supposed to do (as opposed to what a generic collection
should be able to do).

I don't understand what you are talking about. Do you agree with the
addition of #at:put: or do you think RunArrays should not be modified ?

I don't think that makes sense. RunArrays are mainly used to annotate
strings with text formats. It is not really a type of collection that
one should use in your own project. Have a look at
TextAndTextStreamTest, this class already includes a few tests for
RunArray and its intended use.

I don't see why it should not be used for other uses. 

-- 
Damien Cassou





Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Lukas Renggli
> I don't see why it should not be used for other uses.

Have a look at the implementation of RunArray. It is an incredibly
slow and ugly, but space efficient implementation of arrays with many
consecutive elements. This probably made sense around 1980, but
nowadays I doubt that anybody would introduce such a thing anymore ...

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

RE: RunArray immutable?

Nicolas Cellier-3
In reply to this post by Damien Cassou-3

Damien, would you test attachment at http://bugs.impara.de/view.php?id=6070 ?
I'am lazy and did not test it at all, but since you are already writing tests...

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: RunArray immutable?

Damien Cassou-3
[hidden email] wrote:

>
> Damien, would you test attachment at
> http://bugs.impara.de/view.php?id=6070 ?
> I'am lazy and did not test it at all, but since you are already
> writing tests...


In fact, I've already written a "known to fail" test :-) I will try your
code as soon as I'm on the right computer.

Thanks for your patch

--
Damien Cassou