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: a07f3367d7,ae588df7b8719e90,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!news.karotte.org!news.musoftware.de!wum.musoftware.de!news.albasani.net!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada Subject: Imagine Ada with Fewer Attributes Date: Sat, 15 May 2010 16:29:37 -0400 Organization: albasani.net Message-ID: Reply-To: FrankLho.NOSPAM@rcn.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net qQLUjzD9FBcChrD4aEE8tI0bIHPziVc1RZtdhVw0SF7DtnyOGXo9dpeXD9weHd4ixA/pfLt7JCOOilw4ZGIl8w/BQkmbpy4mTBXm5EVM7CNIjyJOuVroDBPU4yiT/plo X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Sat, 15 May 2010 20:29:42 +0000 (UTC) X-User-ID: hUqCn/Igu/U676xDpvR+ecF3vvhdKFxtBlkM4UKKWsE= Cancel-Lock: sha1:VKJ5g8PJnfhmTU8YgwtUUXlDark= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4 X-NNTP-Posting-Host: n6gexhF4ZUd6OVCqyLb182sUF2+sc0GSLzyXIL/fpdo= Xref: g2news2.google.com comp.lang.ada:11645 Date: 2010-05-15T16:29:37-04:00 List-Id: The recent discussion of the 'Image attribute got me thinking of the issue of the whether Ada uses attributes too frequently. I feel that the language would be simpler and easier to use if most of the Ada attributes were replaced with operations. For example, rather than having an 'Image, 'Value, 'Succ, etc. attribute for the scalar types, why not simply have Image, Value, Succ, etc. functions for the scalar types, that the user can override? For example, Warren desired to create an integer type with a user-defined 'Image attribute. I frequently want to do that for enumeration types, where the Ada default (all capitals with underscores) is almost never what is wanted. As noted in the other thread, we cannot change this in Ada 2005. But what if Image were a function instead of an attribute? Imagine an Ada variant where an enumeration type is treated as though it was derived from a base class that defines the functions Image, Value, Pred, Succ etc. Then we could write something like this: type Work_Type is (Tote_That_Barge, Lift_That_Bail); overriding function Image (Item : in Work_Type) return String is -- Base image with underscores replaced with spaces. Spaced : constant String := Ada.Strings.Fixed.Translate( Image (Work_Type'Base (Item)), Underscore_To_Space ); begin return Internationalize (Spaced); end Image; Granted, representation characteristics such as 'Address, 'Size, and 'Position can only be represented by some special construct such as an attribute. Also, many attributes are applied to types and subtypes; to turn these attributes into functions would require that types and subtypes be objects, as they are languages such as Smalltalk. So out of curiosity, which Ada attributes do you think should be turned into functions, and which should stay as attributes? Is there a way to move Ada in the direction of more functions and fewer attributes? -- "All things extant in this world, Gods of Heaven, gods of Earth, Let everything be as it should be; Thus shall it be!" - Magical chant from "Magical Shopping Arcade Abenobashi" "Drizzle, Drazzle, Drozzle, Drome, Time for this one to come home!" - Mr. Wizard from "Tooter Turtle"