From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7f9c4ba3b0dc13ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-13 20:47:20 PST Path: bga.com!news.sprintlink.net!pipex!uunet!gwu.edu!gwu.edu!not-for-mail From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: Addressing functions Date: 13 Dec 1994 20:48:04 -0500 Organization: George Washington University Message-ID: <3clisk$9th@felix.seas.gwu.edu> References: <3citrc$bb5@earth.usa.net> NNTP-Posting-Host: 128.164.9.3 Date: 1994-12-13T20:48:04-05:00 List-Id: In article <3citrc$bb5@earth.usa.net>, Bill Buckley wrote: > >High Ada lovers, I've got a question on storing subprogram address in >Ada. I know I can get the address of a subprogram via the ADDRESS >attribute in Ada but can not figure a way to use it. I don't have any >immediate need for such a procedure but it has my old C-C++ courisity >wondering. For instance if I were to have an array of subprogram addresses >A(1..2) => (1 => Print1'ADDRESS, > 2 => Print2'ADDRESS); >how could I implement the calling these functions (note : I know the >syntax above is wrong but can't get this simple editor to back up to >change it). I have heard from several other Ada programmers that this >may not be possible. You can usually get something reasonably meaningful by casting the address to an integer. Instantiate Unchecked_Conversion: FUNCTION AddressToInt IS NEW Unchecked_Conversion (Source => System.Address, Target => Integer); you can then use a normal Integer_IO instance to display it. If the instance is called My_Int_IO, then My_Int_IO.Put(Item => AddressToInt(Print1'Address), Base => 16); should display it nicely in hexadecimal. Mike Feldman