From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Mon, 07 May 2018 21:19:44 -0700 Organization: A noiseless patient Spider Message-ID: <8736z2zsm7.fsf@nightsong.com> References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <87po2la2qt.fsf@nightsong.com> <87in8buttb.fsf@jacob-sparre.dk> <87wowqpowu.fsf@nightsong.com> <16406268-83df-4564-8855-9bd0fe9caac0@googlegroups.com> <87o9i2pkcr.fsf@nightsong.com> <87in88m43h.fsf@nightsong.com> <87efiuope8.fsf@nightsong.com> <322f9b26-01de-4753-bb50-6ef2f3d993d8@googlegroups.com> <87a7th9pd1.fsf@nightsong.com> <87h8no1nli.fsf@nightsong.com> <87po2cyty7.fsf@nightsong.com> <87bmdwhwob.fsf@nightsong.com> <6746d7d1-406e-4891-8293-9424aed76215@googlegroups.com> <877eoezy6e.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="52b5ce8581a197e35f17678a348070d7"; logging-data="4303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xRUHCclcRNqj4rqzVdhh8" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:s0qxTsbbTDf8hJ5jICe1DO95qjA= sha1:fEGI9LSG1MkXDHiRIyWiL9B/edE= Xref: reader02.eternal-september.org comp.lang.ada:52088 Date: 2018-05-07T21:19:44-07:00 List-Id: gautier_niouzes@hotmail.com writes: > The Zip format is system-agnostic (shameless plug : > https://unzip-ada.sourceforge.io/ ) Nice, I'll check that out. > You are shifting again the subject: the point was to understand with a > simple example how you can use Ada's unconstrained types without > accumulating garbage... There's no issue of accumulating garbage in that example because it's all stack-allocated data. Garbage becomes relevant when you allocate objects that have pointers to other allocated objects, and the objects' lifetimes aren't known in advance. The CBSG avoids creating pointers by copying strings around repeatedly when building large strings from shorter ones. Even still though, the allocation and access pattern is simple enough that stack management suffices. Fwiw, the CBSG's memory consumption is not guaranteed to be bounded because there is no limit on the possible recursion depth, but that's unlikely to be a problem in practice since the probability decreases exponentially with the depth. And one could always add an explicit limit.