Prev: Ada on Wikipedia
Next: Ada and Doxygen
From: Robert A Duff on 23 Feb 2010 16:12 "Randy Brukardt" <randy(a)rrsoftware.com> writes: > <stefan-lucks(a)see-the.signature> wrote in message > news:Pine.LNX.4.64.1002231026050.9207(a)medsec1.medien.uni-weimar.de... > ... >> I am curios: Which of your old favorites didn't work anymore? Which Ada95 >> patterns occur in practice, which are incompatible to Ada05? > > I can't speak for John, but the main incompatibility that we hear about was > the elimination of return-by-reference. While it didn't make much sense, > people managed to make it work for various things and those patterns don't > work anymore. Right, but it's not just return-by-reference. If you return a local limited object, that's legal in Ada 95, but illegal in Ada 2005. If the limited type is immutably limited, that's the return-by-ref case. (Immutably limited means it's really limited deep down -- like a limited private completed with a limited record.) Otherwise (like a limited private completed with an integer type) it's return-by-copy. In AdaCore's test suite, there are something like a couple dozen tests that run into this incompatibility, out of some 15,000 tests. It turns out that the return-by-ref case is something like 1/3 of those, and the return-by-copy case is 2/3. (I measured this when I was involved in implementing the new Ada 2005 build-in-place return feature, but I don't remember the exact numbers). I think it was a language design mistake to apply this rule to the return-by-copy case. If it applied only to the return-by-ref case, it would be less incompatible. Of course, that would break privacy, which is evil. But incompatibilities are even more evil, in my opinion. It would work, because the limited-but-not-inherently-limited case is not build-in-place in Ada 2005 -- it's still return-by-copy. On the other hand, the workarounds for the return-by-copy case are fairly painless -- for example, you can make the type nonlimited. That sort of makes sense anyway, since the limitedness is a lie -- "limited" is supposed to mean "cannot copy", but in fact clients CAN copy in this case (and there's a famous Henry Baker paper about that from Ada 83 days). > We're trying to come up with a sane way to have the same effect (returning > an access value with a limited lifetime and without the need for explicit > dereferencing) for Ada 2012. Hopefully, that capability will allow the > holdouts to come along... Yup. - Bob
|
Pages: 1 Prev: Ada on Wikipedia Next: Ada and Doxygen |