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,e5d23ac8a9173493 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Using a string as a binary operator References: <8cbb04c3-e789-4b67-897a-fd6f83486bbc@x16g2000prn.googlegroups.com> <8d9b43fa-05a1-4024-bbd3-ddf276478748@40g2000prx.googlegroups.com> In-Reply-To: <8d9b43fa-05a1-4024-bbd3-ddf276478748@40g2000prx.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1224091426 12.201.97.213 (Wed, 15 Oct 2008 17:23:46 GMT) NNTP-Posting-Date: Wed, 15 Oct 2008 17:23:46 GMT Organization: AT&T ASP.att.net Date: Wed, 15 Oct 2008 17:23:46 GMT Xref: g2news2.google.com comp.lang.ada:8128 Date: 2008-10-15T17:23:46+00:00 List-Id: Adam Beneschan wrote: > > If-elsif-elsif-elsif-elsif-elsif-else chain? That's not very > imaginative! Why not: > > type Operator_Descriptor is record > Name : access String; > Operation : access function (Left, Right : Integer) > return Integer; > end record; I detest anonymous types. > Although it isn't always possible, I definitely prefer to set things > up in an array or some sort of data structure when possible, rather > than to rely on a 67-branch IF statement or even a CASE statement. By the time you've written all the support functions and the scaffolding to handle both unary and binary operations, your code is at least as big as with the big if statement, and less clear. If you're allowing a client to define the operators and their actions, this would be the way to go, but for hard-coded choices, I prefer the if statement. -- Jeff Carter "Unix and C are the ultimate computer viruses." Richard Gabriel 99