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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ae588df7b8719e90 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Imagine Ada with Fewer Attributes Date: Sat, 15 May 2010 22:46:10 +0200 Organization: Ada At Home Message-ID: References: NNTP-Posting-Host: sTlYSXnTcjJGTYbLtvdIYA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news2.google.com comp.lang.ada:11647 Date: 2010-05-15T22:46:10+02:00 List-Id: Le Sat, 15 May 2010 22:29:37 +0200, Frank J. Lhota = a =C3=A9crit: > The recent discussion of the 'Image attribute got me thinking of the = > issue of the whether Ada uses attributes too frequently. I feel that t= he = > 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? The way is was with Pascal (at least, Borland Pascal). > 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 underscore= s) = > is almost never what is wanted. As noted in the other thread, we canno= t = > change this in Ada 2005. And Ada does not nor prevent you from created such an Image function. > But what if Image were a function instead of an attribute? Interesting question :) > 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 :=3D Ada.Strings.Fixed.Translate( > Image (Work_Type'Base (Item)), > Underscore_To_Space > ); > begin > return Internationalize (Spaced); > end Image; This supposes to have tagged enumeration types and thus to have the =E2=80= =9Call = data types can be seen as classes=E2=80=9D. That's the Eiffel way, which= allows = you to derive a new class from Integer and to have dispatching on = Integer's operation (if my mind is right). > Granted, representation characteristics such as 'Address, 'Size, and = > 'Position can only be represented by some special construct such as an= = > attribute. Agree with you > 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. Indeed > So out of curiosity, which Ada attributes do you think should be turne= d = > into functions, and which should stay as attributes? Well, I don't know, as one can always create a function for Pred, Succ, = = Image and so on as he/she want. Very difficult question... > Is there a way to move Ada in the direction of more functions and fewe= r = > attributes? With all basic types as tagged types ? Is that a joke ? If this is without basic types as tagged types, you will not have = overriding available, and what would you like with functions which you = could not override ? -- = There is even better than a pragma Assert: an --# assert (or a --# = check... question pending)