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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!u31g2000pru.googlegroups.com!not-for-mail From: Natacha Kerensikova Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Sun, 1 Aug 2010 12:43:37 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> NNTP-Posting-Host: 79.82.39.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1280691817 25600 127.0.0.1 (1 Aug 2010 19:43:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 1 Aug 2010 19:43:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u31g2000pru.googlegroups.com; posting-host=79.82.39.29; posting-account=aMKgaAoAAAAoW4eaAiNFNP4PjiOifrN6 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.3) Gecko/20100524 Firefox/3.6.3,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12784 Date: 2010-08-01T12:43:37-07:00 List-Id: On Aug 1, 8:25=A0pm, Jeffrey Carter wrote: > You might very well be able to use something like: > > [snip] Thanks a lot for the example, it really looks like what I'm used to (at least in C). I have to admit I don't really grasp the difference between the vector you use and the Storage_Array, but it seems I have to research it by myself before asking here. > If you can use unbounded strings as Brenta suggested, instead of an unbou= nded > array of bytes (Storage_Element), then this would be even simpler. Actually I'm a bit reluctant to use Ada strings for atoms, because I'm afraid it might somehow interpret the data (e.g. locale or encoding related stuff, or trouble with NUL inherited from C). I occasionally include binary data in S-expressions, and while I keep it on the disk as a text file (using hexadecimal or base-64 encoding), it is the S- expression library's responsibility to load it into memory as the original binary data. On the other hand, most of my atoms are indeed strings, and Character definition from A.1.35 looks exactly like a perfect mapping to bytes. So if Ada strings have no issue with embedded NUL or non-graphics character, and if binary data can be losslessly recovered once stored into an Ada string, it could be the best type for atoms. It will probably be a while before I reach the level of reading the Reference Manual cover-to-cover, does anyone knows whether those "if"s are guaranteed by the standard? Thanks for your help, Natacha