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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!k8g2000prh.googlegroups.com!not-for-mail From: Natacha Kerensikova Newsgroups: comp.lang.ada Subject: S-expression I/O in Ada Date: Sun, 1 Aug 2010 05:17:45 -0700 (PDT) Organization: http://groups.google.com Message-ID: <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 X-Trace: posting.google.com 1280665065 21200 127.0.0.1 (1 Aug 2010 12:17:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 1 Aug 2010 12:17:45 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k8g2000prh.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:12770 Date: 2010-08-01T05:17:45-07:00 List-Id: Hi, I'm trying to learn Ada, coming from a C background. The first thing I planned to code is a S-expression parser, because it's quite easy (at least in C, less than 1000 lines including comments and memory handling (dynamic arrays reinvented)) and very useful considering almost all my existing programs use S-expressions as a serialization format. To describe briefly S-expressions, I consider them to be the simplest existing data organization beyond raw sequences of bits. They are basically lists of elements, each element being either a list or an atom, and atoms being raw sequences of bits. While I'm still not deep enough into Ada to know how to represent the lists, I guess there won't be major issues, I think I can handle it myself (though pointers and hints would still be welcome). My question here is about how to represent the atoms in Ada. In C it was merely a void pointer and a size, but it seems more difficult in Ada because of the strong typing. Because it's up to the application to make sense (i.e. type) out of the raw sequences of bits in atoms, the S-expression library has to handle them as a sort of untyped memory chunk. Do you know of a way to handle that? Please correct me if I'm wrong, but my guess would be that the S- expression library would provide a Sexp_Atom type, which refers to the untyped memory chunks, and the application would have procedures to convert back and forth between Sexp_Atom and whatever types it internally uses (i.e. serialization and deserialization procedures). However the library would provide these procedures for the most common types (e.g. strings and numeric types). Though it looks like a fine Ada API (at least to my eyes), I have absolutely no idea about how to implement the library. How to define the application-opaque Sexp_Atom type? How to read Sexp_Atom objects from a file? How to build them from Ada types? How to write them back to disk? Thanks for your help, Natacha