On 04/18/2013 01:08 AM, Björn Persson wrote:
Florian Weimer wrote:
Yes, Ada has some nice features. At least there are real arrays, but
they are somewhat cumbersome to work with, compared to Java, Python or,
well, C pointers. There are two aspects: preservation of array bounds
in slices (so that you have to write Table (Table'First + Offset) to
access the element Offset of Table, Offset ranging from 0 to
Table'Length - 1)
That array bounds must be preserved becomes obvious when you consider
arrays where the index type has a meaning beyond just position in the
array. If you have an array Week with a range of Monday..Sunday, and
you take the slice Week(Saturday..Sunday) and call it Weekend, then you
really don't want Weekend to suddenly have the indexes Monday and
Tuesday.
Weekdays are a very bad example because it is locale-dependent whether
Monday < Sunday or the other way round. So you really can't fit them
well into an enumeration type, and Java 8 orders the enumeration values
alphabetically by their name, to make that point perfectly clear.
In addition, in Ada, enumeration types can have holes, which makes their
use as array indexes particularly suspect. All this suggests to me that
arrays over enumeration types are probably better served by associative
arrays than by arrays accessed and ordered by some (integer-equivalent)
scalar value.
Controlled types have a fixed overhead which is quite visible with small
objects.
Of course there is always some overhead. Do you mean that they have a
significantly larger overhead than garbage collectors have?
Compared to C++ destructors. Abort deferral takes its toll, and the
last time I looked at this, the front end emitted the finalizer call in
such a way that an indirect call remained in the generated machine code.
(In C++, destructors can be non-virtual.)
--
Florian Weimer / Red Hat Product Security Team
--
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel