Return-Path: X-Original-To: apmail-lucy-dev-archive@www.apache.org Delivered-To: apmail-lucy-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BEF96F9FE for ; Mon, 15 Apr 2013 10:08:49 +0000 (UTC) Received: (qmail 1801 invoked by uid 500); 15 Apr 2013 10:08:49 -0000 Delivered-To: apmail-lucy-dev-archive@lucy.apache.org Received: (qmail 937 invoked by uid 500); 15 Apr 2013 10:08:44 -0000 Mailing-List: contact dev-help@lucy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucy.apache.org Delivered-To: mailing list dev@lucy.apache.org Received: (qmail 99913 invoked by uid 99); 15 Apr 2013 10:08:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Apr 2013 10:08:43 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [212.227.126.187] (HELO moutng.kundenserver.de) (212.227.126.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Apr 2013 10:08:35 +0000 Received: from [192.168.1.39] (dslb-092-074-049-093.pools.arcor-ip.net [92.74.49.93]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MAX6s-1UGB5C2kEU-00BbkH; Mon, 15 Apr 2013 12:08:04 +0200 Message-ID: <516BD17D.5070109@aevum.de> Date: Mon, 15 Apr 2013 12:07:57 +0200 From: Nick Wellnhofer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: dev@lucy.apache.org References: <7D60D702-3184-4B00-8F1B-D1308490E180@aevum.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:btwNYRmEdfAg3qovJdxcWh8+KUpulTMBDkMogYX2y5D ASRFVc6/faQkomhUIAxqcxXAfbKWsh0ifhxyp00mB42kiT/lSA F96uvh4m2zYD4tUwmHDUpYS9F3DTb/Z64sobRN8DrjuxnXkjQa MLCuTVU7XL9gssku5DYInE+xTFsi6fATlQT8lzpoB2C3QSAbIf J6YV1DjsMd8D18Zvm6LSFfNGsrnWx1FRewKmtd2h3MO9qY6pAg HBD52J88cHZBKc8YAbGmW+GnhlNucFGoBUBWzaI8ZcD/xmsjcA f4alNTbCO4ZdsEOGUpnJXe+/qdIBy7EusSG8J12SGF/q3a5ww= = X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [lucy-dev] Initial sketch of string iterators 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`? +1 >> 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. Nick