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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!news4.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!open-news-network.org!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: S-expression I/O in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <1qk2k63kzh7yv$.3jgc403xcqdw$.dlg@40tude.net> <8ae8e899-9eef-4c8c-982e-bfdfc10072f1@h17g2000pri.googlegroups.com> Date: Sun, 1 Aug 2010 20:49:22 +0200 Message-ID: <258zlxrv4fn6.1vszho1rtmf48$.dlg@40tude.net> NNTP-Posting-Date: 01 Aug 2010 20:49:22 CEST NNTP-Posting-Host: 17417baa.newsspool2.arcor-online.net X-Trace: DXC=Dn0PCRP4CWXE47KDAk81NWA9EHlD;3YcR4Fo<]lROoRQ8kFQ4[^WI:PK;E\ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:12783 Date: 2010-08-01T20:49:22+02:00 List-Id: On Sun, 1 Aug 2010 10:35:17 -0700 (PDT), Natacha Kerensikova wrote: > On Aug 1, 2:53�pm, "Dmitry A. Kazakov" > wrote: >> How can it make sense if the type is unknown? If the type is known, why not >> to state it? > > Actually the type is deduced from the context, e.g. > (tcp-connect (host foo.example) (port 80)) Hmm, why do you consider brackets as separate elements? I mean, more natural would be "procedural": tcp-connect (host (foo.example), port (80)) or tcp-connect (foo.example, 80) > This means that as far as the S-expression library is concerned, the byte > sequence read from the file is not typed. Its typing actually has to be > delayed until the application has enough context to interpret it. Hence > the need of a typeless chunk of data. The above is mere syntax, it is not clear why internal/external representation must be as you described. (Actually, the structures as above are widely used in compiler construction e.g. syntax tree, Reverse Polish notation etc.) There is no such thing as untyped data. The information about the type must be somewhere. In your example it could be: type Connect is new Abstract_Node with record Host : IP_Address; Port : Port_Type; end record; So I would derive leaves from some abstract base type and link them into an acyclic graph. It is relatively simple to do using either standard Ada containers or other libraries containing trees and/or graphs. >>> 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? >> >> It is not clear why do you need such a type. What are the properties of, >> and what is it for, given the application need to convert it anyway? > > Well, I imagined making such a new type to distinguish 'raw data coming > from a S-expression to be interpreted' from other raw data types. But you know the type if you are going to interpret raw data. It must be somewhere, hard-coded or dynamically stored/restored. BTW, Ada supports I/O of types (i.e type tags) implicitly in the form of already mentioned stream attributes, but also explicitly by external type tag representations (RM 3.9(7/2)) and generic dispatching constructors (RM 3.9(18/1)). > I thought this was the strong type safety to prevent (de)serialization > procedure from trying to interpret just any chunk of memory. No, actually it eases serialization because you can define Serialize/Unserialize operations on the type. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de