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,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!y35g2000prc.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Tue, 8 Feb 2011 14:30:42 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <4d4ff70e$0$6886$9b4e6d93@newsspool2.arcor-online.net> <737a6396-72bd-4a1e-8895-7d50f287960e@d28g2000yqc.googlegroups.com> <4d5008a5$0$6879$9b4e6d93@newsspool2.arcor-online.net> <4d5031fe$0$6765$9b4e6d93@newsspool3.arcor-online.net> <1f229967-d3cf-42b6-8087-c97ee08652f3@i40g2000yqh.googlegroups.com> <4d51169e$0$7657$9b4e6d93@newsspool1.arcor-online.net> <1bnp0pw1c8r5b$.guxc48qweiwe.dlg@40tude.net> <4d51a1c0$0$19486$882e7ee2@usenet-news.net> <4d51b568$0$19486$882e7ee2@usenet-news.net> NNTP-Posting-Host: 174.28.151.164 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297204243 19593 127.0.0.1 (8 Feb 2011 22:30:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Feb 2011 22:30:43 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y35g2000prc.googlegroups.com; posting-host=174.28.151.164; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:17059 Date: 2011-02-08T14:30:42-08:00 List-Id: On Feb 8, 2:25=A0pm, Hyman Rosen wrote: > > Because managers have had reinforced the erroneous idea that: > > "C is the *only* valid systems-level language." for one. > > Huh? Web, smart-phone, and other complex interfaces exist > because of C? That makes no sense. You didn't read that right, or perhaps I didn't express it right; and what you point to is really the beginning of the manager- section of software-engineering projects seeing that C/C++ *isn't* required to do system-level work. > >> How do you test the third bit of a byte in Ada? > > > One Way, assuming a 1..8 numbering for an 8-bit byte: > > =A0 SubType Bits is Positive Range 1..Byte'Size; > > =A0 Type Bit_Mask is Array ( Bits'Range ) of Boolean; > > =A0 For Bit_Mask'Size use Byte'Size; > > > Function Test_Bit( Value : In Byte; Bit : In Bits ) =A0Return Boolean i= s > > =A0 =A0Mask : Bit_Mask; > > =A0 =A0For Mask'Address use Value'Address; > > =A0 =A0Pragma Import( Ada, Mask ); > > begin > > =A0 =A0Return Mask(Bit); > > end Test_Bit; > > I think that's why I'll stick with (byte & (1 << (3 - 1))). > Or rather, I would most likely write a macro, > =A0 =A0 =A0#define TEST_BIT(n, b) ((n) & (1 << ((b) - 1))) Why? Isn't that the purpose of a function to reuse code? And if you're going to say that's what the macro does, then what problem is there with using Pragma Inline? > Then the Ada people who see errors in every line of C code > would come after me complaining about how terrible my code > is, and what if the macro is invoked with zero or negative > or too high bit number. Er, why are you making such a statement to me? Have I said anything about how horrid your code is? Have I given you a "what if" just to be an ass? Have I not been willing to discuss the whole matter as equals? > >> *Why* do you test the third bit of a byte in any language? > > > Why does a hardware device set the third bit of some information? > > To communicate. > > Except for DK, who granted was actually interviewing people to work > with such hardware devices, programming doesn't really involve such > bit twiddling any more. Which is why I said that as long as new devices were being developed we need "bit-twiddling." And in fact Ada was designed to meet some of the very needs of that sort of bit-twiddling: representation clauses, for one. > It doesn't even involve being able to design > data structures much any more either. These days, someone working in > Java or C++ will just pick an appropriate container class from the > library and use it, and it will be good enough. And isn't that the whole point of the gripe DK was making?