From: "Frank J. Lhota" <FrankLho.NOSPAM@rcn.com>
Subject: Imagine Ada with Fewer Attributes
Date: Sat, 15 May 2010 16:29:37 -0400
Date: 2010-05-15T16:29:37-04:00 [thread overview]
Message-ID: <hsn07m$acs$1@news.albasani.net> (raw)
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"
next reply other threads:[~2010-05-15 20:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-15 20:29 Frank J. Lhota [this message]
2010-05-15 20:46 ` Imagine Ada with Fewer Attributes Yannick Duchêne (Hibou57)
2010-05-16 7:11 ` Dmitry A. Kazakov
2010-05-16 15:31 ` Robert A Duff
2010-05-17 13:27 ` Colin Paul Gloster
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox