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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,43ad9ab56ebde91c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.2 with SMTP id gm2mr4401360pbc.4.1323940457283; Thu, 15 Dec 2011 01:14:17 -0800 (PST) MIME-Version: 1.0 Path: lh20ni24692pbb.0!nntp.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.nethere.com!news.nethere.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 15 Dec 2011 03:14:16 -0600 Newsgroups: comp.lang.ada Subject: Re: Does Ada support endiannes? From: csampson@inetworld.net (Charles H. Sampson) Date: Thu, 15 Dec 2011 01:14:15 -0800 Message-ID: <1kcakce.17lpouc1o2nz0gN%csampson@inetworld.net> References: <23835087-313f-427c-b37e-4ff1bdef9d57@r6g2000yqr.googlegroups.com> <20e631fc-e7b4-41ca-be0f-aab8be3f9a25@f33g2000yqh.googlegroups.com> <53n2sd7edt5i.1boh4452h0aks.dlg@40tude.net> <1kc5n51.ffg0umddufyfN%csampson@inetworld.net> <1c2ax12bptm2g.gifwv5vndpxe$.dlg@40tude.net> <1kc8f2j.132xw621jmu761N%csampson@inetworld.net> <16jibtpb9f2o4.1pf3ro8hb8qq2.dlg@40tude.net> User-Agent: MacSOUP/2.8.2 (Mac OS X version 10.4.11 (PPC)) X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-EUmaCme9voeRmg/S9Wl3JEn3APZOFJSDrQegf6mtEGh4WSBTygRyv3VVZVRekQ8dmruLNiK6t5fD9na!PdOnMF5vCWBOJyxYe5R2jEtx7x6CqWtSeHVS6b3WqQScYtl8dslJQYX0qYaRE0bKA6codgXIVdZl!k3FwivHSfE1db7yeYctR3T8WbM4o X-Complaints-To: abuse@nethere.com X-DMCA-Complaints-To: abuse@nethere.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 6250 Date: 2011-12-15T01:14:15-08:00 List-Id: Dmitry A. Kazakov wrote: > On Tue, 13 Dec 2011 21:19:07 -0800, Charles H. Sampson wrote: > > > Dmitry A. Kazakov wrote: > > > >> No. The Ada's design goal was to allow the programmer to describe the > >> semantics the data types involved and to program in that terms. > >> Representation clauses rather defeat that idea than support it. The number > >> read from the wire must look and feel as a number rather than some messy > >> record, which cannot be a numeric parameter of a generic, has no 'Image, no > >> meaningful literals etc... > > > > I think I see the place where we have the greatest disagreement in > > concept. To me, in general, data coming "over a wire" are just a stream > > of bits until we have interpreted them and found out what they mean. > > Right, I prefer typed approaches over untyped ones. This is BTW why I > prefer Ada over other languages. > > Stream of bits is a transport layer, at best, to be hidden under higher > protocol layers, spilling properly typed objects to the clients. No > conversions. One advantage of this approach is that the transport being > properly encapsulated could be easily replaced. Well, yes. You do definitely want to encapsulate all this stuff. Even though the ugly stuff is hidden to from the clients, I still want to make the ugly stuff as pretty and understandable as possible. > > At that requires a bit more writing than your approach, Dmitry, but > > that's o. k. with me. The design of Ada was permitted to require > > "extra" writing for the purpose of clarity of code. > > I think the problem here is not the volume of the code, but an untyped > nature of it. My code gets "typed" as soon as possible, as soon as I can recognize what its type is supposed to be. The reason I wrote _typed_ in quotes is that a stream of bits, where I start, is typed: type Bit is range 0 .. 1; for Bit'Size use 1; type Bit_Stream is array (Positive range <>) of Bit; pragma Pack (Bit_Stream); > Note that if the native and remote objects were distinct types (not > subtypes), you would not be able to have them as views of the *same* > object. Thus you would have to convert the remote object to a native one. > But once you had the latter you would not need the former anymore. The next > step is just to get rid of it. Why anybody (a client) should see it at all? > That is my approach. The only time I need two views of an object when I need to access its components, such as when constructing the object or accessing its components to, for example, construct some other object from them. I absolutely agree that you should get numeric values into a proper native type as soon as possible. This conversion between native and non-native type should be confined to IO time. Sometime the time between the IO and the conversion is longer than you might hope, at least on the input side. Referring again to the last system I worked on, we often had to read part of the input to determine the length of the incoming bit string, then read the rest in, and then begin the checking to determine exactly what we had. > As a by-product you get a highly portable code as Gautier pointed out in > another response. I don't understand this claim of highly portable code without using a rep spec. A rep spec is necessary to insure proper allocation of a record's components. Your earlier questioning of the order of the components in my definition of the type Single_Precision leads me to think that you aren't aware that there is no link between the lexical order of a record type definition and the layout of its components in memory. In other words, a compiler is free to "move components around". They usually do this to achieve an efficient memory layout but they could do in just on a whim of the compiler writer. > IMO, representation clauses are evil and not Ada (TM). IMO, representation clauses are a blessing that allows me to take full control of the representation when I need to. That's one of many reasons why I prefer Ada to any other language I know, to the point that I refuse to program in any other language. (Being past retirement age has certain benefits.) By the way, Dmitry, I hope you understand that by carrying on this dialog I don't intend to imply that you're a idiot who has no idea what he's doing. That's obviously not true. All I'm trying to do is lead you to enlightenment by exposing you to my clearly superior ideas. :-) Charlie -- [A certain TV newsreader] had a role to play: presenter of the Other Side of the Argument, to whom fair-minded people were obligated to pay heed, no matter what nonsense he spouted. Charlie Pierce, Idiot America