Version 1.1 of acs/ac-00100.txt

Unformatted version of acs/ac-00100.txt version 1.1
Other versions for file acs/ac-00100.txt

!standard 13.11          04-06-02 AC95-00100/01
!class amendment 04-06-02
!status received no action 04-06-02
!status received 04-05-05
!subject Dereference hook

From: Mike Card
Sent: Wednesday, May 5, 2004  7:23 AM

Hello everyone-

I have been following discussions about the proposed revisions for Ada 2005 and
I have not seen mention of a feature I would like to see in the language,
namely a user-definable "dereference hook" that would be called on all pointer
dereferences for the associated access type. The user's dereference hook
procedure would be associated with an access type using a new type attribute,
something like 'dereference_hook. This attribute woujld only be valid for
access types. What I had envisioned was something like this:

type my_access_type is access some_type;
for my_access_type'dereference_hook use my_deref_hook;

-- my_deref_hook must match this signature
procedure dereference_hook (
        obj_address : in System.Address; -- ptr.all'address passed in
        dot_all : in Boolean;  -- true if dereference was result of ptr.all
        field_offset : in System.Storage_Elements.Storage_Offset;
        -- This field contains the offset into the object for cases where
        -- the dereference is ptr.field1 instead of ptr.all. A value of
        -- zero indicates that the dereference is pointing to the first \
        -- field in the object
        LHS : in Boolean
        -- true if dereference occurs on left hand side of an assignment
        -- statement, i.e. ptr.field := some_value;

I don't think this should be a difficult thing for the compiler implementors as
this is all information the compiler generates anyway for dereferencing. This
kind of "tell me when a pointer is being dereferenced" procedure would be very
useful when building an object database. I am currently doing some work in Ada
object databases again and would love to have something like this in the
language, it would make the APIs for the application developer a lot simpler
and make the Ada object database easier to use.

For exception handling, I would propose that exceptions occurring in the
dereference hook be passed out to the caller if they are not handled inside the

Is a feature like this already included, and if not, is it too late to add it
in for consideration? [It's too late - ED]

Thank you all for your time,


Questions? Ask the ACAA Technical Agent