[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: API Design
- From: Russell Haley <russ.haley@...>
- Date: Mon, 18 Sep 2017 12:22:17 -0700
On Mon, Sep 18, 2017 at 11:48 AM, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
> b = Buffer(1024)
> s1 = b:Segment(128, 256) -- from 128 to 384
> s1 = b:Segment(128):size(256) -- from 128 to 384
> s1 = b:Segment(128):to(384) -- from 128 to 384
> s2 = b:Segment(439) -- from 439 to 1024
> s3 = b:Segment() -- from 0 to 1024
> s4 = b:Segment():size(128) -- from 0 to 128
> s5 = b:Segment(128):to(384):next() -- from 384 to 640
> s5 = b:Segment(128):to(384):shift(10) -- from 138 to 394
+1.
b:Segment() - I would think this would be 0 to the length of the buffer.
I like the :next() and :shift() ideas, but that would mean the module
would need internal state on what the size of the 'chuck' would be?
Perhaps:
cs = 256
s4 = b:Segment(128,cs):next(cs)
or if state IS desired:
b.def_chuck_size = 256
s4 = b:Segment(128):next()
But that gets pretty messy I think... Maybe:
offset = 128
b.def_chuck_size = 256
s1 = b:Segment(offset)
sx = b:Next()
That just seems to add complication for syntax though.
Russ