[squeak-dev] The Trunk: Kernel-eem.1117.mcz

Bert Freudenberg bert at freudenbergs.de
Fri Nov 10 16:36:56 UTC 2017


On Fri, Nov 10, 2017 at 11:44 AM, Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com> wrote:

>
>
> 2017-11-10 10:53 GMT+01:00 Tobias Pape <Das.Linux at gmx.de>:
>
>>
>> > On 10.11.2017, at 08:00, Nicolas Cellier <nicolas.cellier.aka.nice at gmai
>> l.com> wrote:
>> >
>> > But old implementation was a to:do: loop on indices with (self tempAt:
>> i)
>> > So we already pay the price of low level procedural style,
>> > why having to pay the stream overhead?
>> > It makes code more convoluted than necessary (a higher level dsiguise)
>> >
>> > Or should we rewrite most of SequenceableCollection protocol?
>> >
>>
>> I don't get it.
>>
>> Best regards
>>         -Tobias
>>
>>
> Hi Tobias,
> I say that the main interest of stream is to release you from direct index
> manipulation
> which are considered as lower level implementation details
>
> The code below is just doing a copy.
> It was done with low level index iteration on one side for reading,
> and invoking higher level stream on the other side for writing,
> despite the fact that the low level indices would perfectly match...
>
> We are thus complexifying the code un-necessarily by using two concepts
> where a single one would have been enough.
> Incidentally, code was less efficient, but I don't know if we ever have to
> care (maybe Eliot cares for VM simulation).
>
> So that's why I call this a higher level disguise: it's fake since we
> continue manipulating low level indices.
>
> SequenceableCollection if full of those low level iterations on indices,
> but there it's mainly for the sake of speed/efficiency.
>

​+1

The streamContents: variant is both inefficient and inelegant.

Eliot's version is inelegant too, but efficient.

This one would be elegant but inefficient, as mentioned in Eliot's comment:

arguments
      ^(1 to: self numArgs) collect: [:i | self tempAt: i]

If we wanted it to be elegant and efficient, we would have to write it like

arguments
      ^1 to: self numArgs collect: [:i | self tempAt: i]

... and expand to:collect: in the Compiler just like #to:do: is expanded.

I have wished for a to:collect: method numerous times, maybe we do actually
want this?

- Bert -​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20171110/5fb5d610/attachment.html>


More information about the Squeak-dev mailing list