lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Wellnhofer <>
Subject Re: [lucy-dev] Initial sketch of string iterators
Date Mon, 15 Apr 2013 10:07:57 GMT
On 14/04/2013 04:25, Marvin Humphrey wrote:
> Good point.  How about a symbolic value, `DONE`, or in full,
> `CFISH_CBITER_DONE` and eventually also `CFISH_STRITER_DONE`?


>> After reaching the end of the string, I can see two options which both have
>> their pros and cons:
>>      * Change to a new iterator state ("beyond string boundary") and throw
>>        an exception on every subsequent access (like in your example below).
>>      * Keep returning the sentinel value on calls to Next() but allow to
>>        move backward via Prev(). This can result in an infinite loop in
>>        faulty code.
> I don't have a strong opinion.

I lean towards the second option.

> What do you think of putting a flag into CharBuf/String which indicates how it
> should deallocated?
>      void
>      CB_destroy(CharBuf *self) {
>          if (!(self->flags & CB_HEAP_ALLOCATED)) {
>              THROW(ERR, "Can't Destroy non-heap-allocated CharBuf");
>          }
>          ...
>      }
> That would allow us to get rid of the Zombie classes.  Rationale: using
> subclassing to control memory allocation is odd, plus the name "Zombie" isn't
> the greatest.

I think it's a good idea but I wouldn't want to waste a whole word in 
the CharBuf struct just for a single flag.


View raw message