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!feeder.news-service.com!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool1.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> <258zlxrv4fn6.1vszho1rtmf48$.dlg@40tude.net> <984db477-973c-4a66-9bf6-e5348c9b95f2@n19g2000prf.googlegroups.com> <46866b8yq8nn$.151lqiwa0y2k6.dlg@40tude.net> <13b07f2c-2f35-43e0-83c5-1b572c65d323@y11g2000yqm.googlegroups.com> Date: Sat, 7 Aug 2010 16:23:33 +0200 Message-ID: <13tpf7ya3evig$.h05p3x08059s$.dlg@40tude.net> NNTP-Posting-Date: 07 Aug 2010 16:23:33 CEST NNTP-Posting-Host: e412dfce.newsspool4.arcor-online.net X-Trace: DXC=4Inf7\K14dMAa;:RKVJ>LE4IUK\afO[7fV[n]UKCA X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:12932 Date: 2010-08-07T16:23:33+02:00 List-Id: On Sat, 7 Aug 2010 05:56:50 -0700 (PDT), Natacha Kerensikova wrote: > On Aug 7, 10:39�am, "Dmitry A. Kazakov" > wrote: >> One cannot judge a format without knowing what is the purpose of. Most of >> the formats like S-expressions are purposeless, in the sense that there is >> no *rational* purpose behind them. As you wrote above, it is either legacy >> (we have to overcome some limitations of some other poorly designed >> components of the system) or personal preferences (some people like angle >> brackets others do curly ones). > > Why can't there be general-purpose format, just like there are general- > purpose programming languages? An interesting question. I would say no, there cannot be such formats. Any presentation format is of course a language. The only difference to the true programming languages is in complexity, any maybe in a tendency to being declarative rather than imperative. There are border cases like Postscript, which IMO illustrate the point, more general purpose it has to be, less "format" it would become. > Can we at least agree on the fact that a sequence of bytes is a > general-purpose format, widely used for storing and transmitting data? > (this question is just a matter of vocabulary) I don't think so. Namely it don't think that "general" is a synonym to "completeness." It is rather about the abstraction level under the condition of completeness. > So let's add as few semantics as possible, to keep as much generality > as possible. We end up with a bunch of byte sequences, whose semantics > are still left to the application, linked together by some kind of > semantic link. When the chosen links are "brother of" and "sublist of" > you get exactly S-expressions. Yes, the language of S-expressions is about hierarchical structures of elements lacking any semantics. I see no purpose such descriptions. But this is a very old and bearded issue. The same question arise when it is discussed why RDBMS are so boring. For the same reason: a naked structure, be it relational, hierarchical, whichever, is useless without the semantics. The semantics when dealt with, is capable to catch such simple relationships as "sibling" with no efforts. DB people believe that one could bridge the gap and somehow come to the semantics from the structure's side. Translated into your S-expressions, it is by putting a proper pattern of opening and closing brackets one could describe everything... > However from a purely practical point of view, and using the fact that > in my background languages (C and 386 asm) bytes sequences and strings > are so similar, these crude semantics are all I need (or at least, all > I've ever needed so far). Lower you descend down the abstraction levels less differences you see. Everything is a bunch of transistors... > Now if we agree that simplicity is a > desirable quality (because it leads to less bugs, more productivity, > etc), I still fail to see the issues of such a format. Programs in 386 Assembler are sufficiently more complex than programs in Ada. Simplicity of nature by no means implies simplicity of use. > Now regarding personal preferences about braces, I have to admit I'm > always shocked at the way so many people dismiss S-expressions on > first sight because of the LISP-looking parentheses. Do you mean LISP does not deserve its fame? (:-)) >>>>> But now that I think about it, I'm wondering whether I'm stuck in my C >>>>> way of thinking and trying to apply it to Ada. Am I missing an Ada way >>>>> of storing structured data in a text-based way? >> >>>> I think yes. Though it is not Ada-specific, rather commonly used OOP design >>>> patterns. >> >>> I heard people claiming that the first language shapes the mind of >>> coders (and they continue saying a whole generation of programmers has >>> been mind-crippled by BASIC). My first language happened to be 386 >>> assembly, that might explain things. >> >> I see where mixing abstraction layers comes from... > > Could you please point me where I am mixing what? Encoding, representation, states, behavior, values, objects, everything is a sequence of bytes, so? > My point is, most of my (currently non-OOP) code can be expressed as > well in an OOP style. When I defined a C structure along with a bunch > of functions that perform operations on it, I'm conceptually defining > a class and its methods, only expressed in a non-OOP language. I > sometimes put function pointers in the structure, to have a form of > dynamic dispatch or virtual methods. I occasionally even leave the > structure declared but undefined publicly, to hide internals (do call > that encapsulation?), along with functions that could well be called > accessors and mutators. In my opinion that doesn't count as OOP > because it doesn't use OOP-specific features like inheritance. I disagree because in my view this is all what OO is about. OO is not about the tools (OOPL), it is about the way of programming. >>> The >>> problem is, I just can't manage to imagine how to go in a single step >>> from the byte sequence containing a S-expression describing multiple >>> objects to the internal memory representation and vice-versa. >> >> You need not, that is the power of OOP you dislike so much. > > I don't dislike at all. I just seldom think that way. I've met people > who saw objects everywhere, while I tend to see bunch of bits > everywhere. Yes, I know them too. I don't believe that everything is object. But I do believe in abstract type systems, that every object in a well-designed program must have a type and that type shall describe the behavior as precise as possible. > And the reason why I started this thread is only to > know how to buffer into memory the arrays of octets, because I need > (in my usual use of S-expressions) to resolve the links between atoms > before I can know the type of atoms. So I need a way to delay the > typing, and in the meantime handle data as a generic byte sequence > whose only known information is its size and its place in the S- > expression tree. What exactly is so bad with that approach? Nothing wrong when at the implementation level. However I don't see why links need to be resolved first. In comparable cases - I do much messy protocol/communication stuff - I usually first restore objects and then resolve links. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de