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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,11e34713e74457c X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Conversion of access types ... Date: 1997/05/03 Message-ID: <336B8CB6.4A2C@sprintmail.com>#1/1 X-Deja-AN: 239149886 References: <5k64m8$jv4@taxis.corp.titan.com> Organization: Sprint Internet Passport Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-03T00:00:00+00:00 List-Id: > t_mjb@linkabit.titan.com writes: [snip] > > I am trying to convert a variable of type P to an unsigned long > > (ULONG) which will allow me to pass this value on to a system > > procedure which will, when the data finally arrives at its > > destination, will be converted back into type P. Well, you could just instantiate Unchecked_Conversion: with Ada.Unchecked_Conversion; ... function P_To_ULONG is new Ada.Unchecked_Conversion (P, ULONG); Your_P : P; ... Your_C_Routine ( ..., P_To_ULONG(Your_P), ...); But then again, why bother... Simon Wright wrote: > > I had a similar problem (calls to my own C procedures, actually, but > equivalent) and found that I could declare the C procedure using the > Ada access types with pragma Import: [snip] Exactly. Remember, everything in the computer is just bits and bytes. Whether you're talking Ada95 or C or whatever, _all_ data types -- even seemingly "simple" ones such as integers -- are just abstractions layered on top of the bits and bytes. High order languages are really just an illusion. It's a very _useful_ illusion, and the discipline of adhering to that illusion reaps benefits in increased programmer productivity. But it's still just an illusion. So whenever you need to push beyond the boundaries of your programming language to interface with external hardware or code in other languages, you have the liberty to pick which illusion you want to map onto the outside world. If you have to pretend that those four bytes are something, why bother pretending they're a ULONG? You could just as easily pretend they're your access type directly. As long as the bit-representation is the same (you _do_ have to know what you're doing), one pretense is as good as another! :-) ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: The World's *FIRST* International-Standard OOPL", Disclaimer => "These opinions were never defined, so using them " & "would be erroneous...or is that just nondeterministic now? :-) "); ------------------------------------------------------------------------