[Cuis-dev] fileout. proposed 2 new methods for strict file chunks reading

Hernan Wilkinson hernan.wilkinson at 10pines.com
Thu Oct 21 05:53:19 PDT 2021


Hi Nicola,
 I see your point regarding the functionality of upTo:, but you can easily
overcome that using #peekBack. Using you example:
-----
s _ 'hello-1Ahello-2Ahel'.
'/tmp/test.txt' asFileEntry fileContents: s.

st1 _ '/tmp/test.txt' asFileEntry readStream .

st1 upTo: $A. " 'hello-1' "
st1 upTo: $A. " 'hello-2' "
st1 upTo: $A. " 'hel' "
(st1 atEnd and: [ st1 peekBack ~= $A ]) ifTrue: [ self error: 'End of file
without delimiter ].
------

 Regarding my concern of adding this functionality to Cuis, we are trying
to have a compact set of classes and methods to reduce complexity (or at
least not increase it) and help newcomers to understand it and oldies to
remember it :-) . We are also trying to add more and more tests because it
is the only way to keep a system from becoming a legacy one and to reduce
the fear it produces to change something.
 The strictUpTo:startPos: you are sending is almost a copy of the upTo:
method, with a few lines changed. Even though the functionality makes sense
(although right now you are the only one needing it and as I said, you can
use peekBack to overcome it), adding that method adds repeated code which
in the long term makes it more difficult to understand and maintain, even
more because it does not have tests.
 So I hope you understand that as maintainers of Cuis, we want to be loyal
to the goals I mentioned before and keep Cuis as clean and simple as
possible. If you can refactor what you sent to avoid having repeated code
with #upTo: and add tests that verify the functionality of both methods
(strictUpTo: and upTo:), that will make our task easier and meet the goals
we have. If you think this does not make sense to you, or you do not have
the time to do it, it is completely understandable and in that case I
suggest for you to have it as an extension of the StandardFileStream class
or just use the peekBack message as I showed.
 I hope you understand my concern and agree with me. If not, please let me
know.

Cheers!
Hernan.


On Tue, Oct 19, 2021 at 10:32 AM Nicola Mingotti <nmingotti at gmail.com>
wrote:

>
> Hi Hernan,
>
> In all frankness, in I would wipe out the old 'upTo' because its behavior
> is a bit "wild".
>
> On the other side, I understand it may create problems in
> retro-compatibility, that is why for
> the moment i propose to add a new method which behaves a bit better.
>
> I hope this example explains the problem:
> -------------------------------------------------------
> s _ 'hello-1Ahello-2Ahel'.
> '/tmp/test.txt' asFileEntry fileContents: s.
>
> st1 _ '/tmp/test.txt' asFileEntry readStream .
>
> st1 upTo: $A. " 'hello-1' "
> st1 upTo: $A. " 'hello-2' "
> st1 upTo: $A. " 'hel' "         "(*)"
> ------------------------------------------------------
> (*) You can't establish in any way if you actually found an "A" terminated
> block or just hit the end of file
> (*) If you hit the end of file you eat an incomplete record, this is
> another problem, maybe another process
> was going to end writing that record but you will never know.
>
> Maybe there is another method around that performs similarly to
> 'strictUpTp', if there is I did not find it, sorry.
>
> IMHO, In a scale of importance from 0 to 10, this method, for a
> programmer, >= 8.
> I would definitely not put it into an external package, too much
> fundamental.
>
> bye
> Nicola
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On 10/19/21 14:44, Hernan Wilkinson wrote:
>
> Hi Nicola!
>  I was wondering, why are you suggesting adding them to the base? Is it
> not enough to implement them as an extension in your package?
>  Also, I think that any new functionality should come with its
> corresponding tests to help the maintenance and understanding of the
> functionality.
>
> Cheers!
> Hernan.
>
>
> On Tue, Oct 19, 2021 at 7:04 AM Nicola Mingotti via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> Hi Juan, guys,
>>
>> I would like to add to Cuis the 2 methods i attach here. One is a helper
>> method.
>>
>> -----------
>> StandardFileStream strictUpTo: delim.
>> -----------
>>
>> Differently from 'upTo: delim' this method:
>> 1. Does not return stuff if it does not find 'delim'.
>> 2. Does not upgrade the position on the stream if does not find 'delim'.
>> 3. If it finds 'delim' returns a chunk that includes it.
>>
>> I am parsing log files at the moment, this is very much useful.
>>
>> NOTE. Up to now I tested only on small files.
>>
>> bye
>> Nicola
>>
>>
>>
>>
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
>
> --
> <https://10pines.com/> Hernán Wilkinson Software Developer & Coach
>
> Alem 896, Floor 6, Buenos Aires, Argentina
>
> +54 11 6091 3125
>
> @HernanWilkinson
>
>
>

-- 
<https://10pines.com/>Hernán WilkinsonSoftware Developer & Coach

Alem 896, Floor 6, Buenos Aires, Argentina

+54 11 6091 3125

@HernanWilkinson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20211021/ef91544f/attachment.htm>


More information about the Cuis-dev mailing list