Re: volatile vs aliased



Randy Brukardt wrote:

This seems like a good time to mention that I think the explicit use of
System.Address in Ada 95 and Ada 200Y code is usually a mistake. Since
pragma Convention can be used to ensure that general access types have the
appropriate representation, its rare that Address needs to be used for
interfacing. (There is only a handful of uses of Address in Claw, for
example.)

I'd go further. First, I see if I can use an out or in out parameter of a Convention-C non-access type, rather than use a Convention-C access type. Most pointer parameters in C exist to get the effect of out or in out parameters, and "pragma Import (C, ..." will do the right thing for you without messing with access types.


Of course, if the C function has both pointer parameters and returns a value, access parameters are the only thing available. Is ease of interfacing to other languages another pro for allowing out and in out parameters for functions, along with making side effects visible?

--
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71
.



Relevant Pages

  • Re: pointer questions
    ... > True, but then you're not using Ada, you're using Ada and X, which I ... > so the code I write doesn't contain those access types. ... >> If I designed a language, I would go even further in that direction. ... >> I would allow mutually recursive types without intervening pointers. ...
    (comp.lang.ada)
  • Re: Heap Memory Management Question(s)
    ... I've been thumping through the LRMs for both Ada ... Ada 2005 allows anonymous access types ... T_ptr, so, at first sight, a clever compiler could deallocate these ... pointer to a local collection, return from the procedure, then reenter ...
    (comp.lang.ada)
  • Re: pointer questions
    ... you never need the kind of pointers the OP was asking about. ... Instead, I reuse existing generic data structures, so the code I write doesn't contain those access types. ... For learning Ada, one should write some dynamic data structures, but to use Ada, you should reuse existing dynamic data structures. ...
    (comp.lang.ada)
  • Re: pointer questions
    ... I use pointers all the time. ... anonymous access types -- there are probably hundreds of those ... You need pointers in Ada whenever you have complex data ... If I designed a language, I would go even further in that direction. ...
    (comp.lang.ada)
  • Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)
    ... > instantiations are inherently unsafe. ... It isn't different than Ada access types, ... That's an important design issue when designing reusable libraries. ...
    (comp.lang.ada)