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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ded6ba3fc5b87b66 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-26 07:50:06 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: First time Ada has let me down Date: Thu, 26 Oct 2000 14:36:33 GMT Organization: Deja.com - Before you buy. Message-ID: <8t9fhh$h83$1@nnrp1.deja.com> References: <8FD7DEBEEsynoptikdamudderfuck@news> <8FD8A9ED5andrewloguecdcgycom@142.77.1.194> NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Thu Oct 26 14:36:33 2000 GMT X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) X-Http-Proxy: 1.0 x66.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:1574 Date: 2000-10-26T14:36:33+00:00 List-Id: In article <8FD8A9ED5andrewloguecdcgycom@142.77.1.194>, nospam.andrew.logue@cdcgy.com (Shifty) wrote: > something like this: > > function Calculate_Ip_Header_Length > (Byte_At : in System.Address) return Integer is > > Version_Length_Descriptor : Octet_Type; > for Version_Length_Descriptor use at Byte_At; If you feel you *have* to do this kind of thing, I'd generally prefer to see Byte_At unchecked_Converion'ed into an object of type "access Octet_Type". I don't ever use "for use at" to alias things, as it obfuscates the code. If a reader sees "Unchecked_Conversion", they have a pretty good idea what's going on. Its a debatable point though. > Version_Mask : constant Integer := 2#00001111#; > > -- Mask it. > -- > Length : Integer := V_Bits.Bit_And (Temp, Version_Mask); > I don't want to start a war over this, since there is _always_ a In that case, it appears you picked an unfortunate subject name. It seems your real problem isn't that "Ada let you down", but that an obsolete version of Ada isn't letting you do things the exact way you'd do them in C (at least not without resorting to compiler extensions) :-) Of course I can name a couple of other situations where Ada 83 really is liable to "let you down". That's why the language was revised. > better way of doing things, but this solution seems simple and > elegant, especially when I don't give hoot about the rest of the > header structure. You just pass the start address of the IP datagram > to this function and it quickly returns the byte-length of the header. > (assuming, of course, that Hlen contains the right value!) > > Thankfully Ada95 has native language support for bitwise integer > operators. I'd say you're pretty much on the money. Of course if you don't care about any of the other fields, you could just as easily use a record with only the one field you care about rep'ed, and then you wouldn't have to worry about the masking (and it would probably be clearer to a reader what is going on). If it were me, I don't think I'd do it the way you're doing it. But you can get it to work that way. If everyone did everything the way *I* think it should be done, it'd probably be a pretty surreal world. :-) -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.