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,fee8802cc3d8334d X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,fee8802cc3d8334d X-Google-Attributes: gid10a146,public From: Marin David Condic Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/17 Message-ID: <3769541B.CE714797@pwfl.com>#1/1 X-Deja-AN: 490792549 Content-Transfer-Encoding: 7bit Sender: condicma@bogon.pwfl.com References: <7jt2c0$vrb@drn.newsguy.com> <7k57vb$1ipf@drn.newsguy.com> <3766650F.705125B7@pwfl.com> <37694942.2C87628A@mitre.org> Content-Type: text/plain; charset=us-ascii Organization: Pratt & Whitney Mime-Version: 1.0 Reply-To: diespammer@pwfl.com Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-17T00:00:00+00:00 List-Id: Robert I. Eachus wrote: > > Interesting question, but far from this topic... If you want a > type with negative numbers that wraps around in Ada, how do you do it? > Pragma Suppress is the easiest solution, but it is not guarenteed to > work portably, or even to work at all. You can derive a type from a > modular type and override the comparison operators, etc. This is > probably the best route. The cleanest way from a users point of view is > probably to derive from Integer and override the arithmetic operations. > This does have the problem with reemergence of the predefined operators > (see RM 12.5(8)) in a generic when one of these types is passed as a > generic formal integer type rather than a generic formal derived type. > However, I think that this is probably the right behavior--let the > author of the generic worry about overflow inside the generic. If you > want to use the redefined operators, you can always pass them as genric > formal subprograms. > Are you sure you would want to "derive* a type? Or just declare your own integer type? Obviously, you override the operators - most likely dipping into assembler to implement them. Still, we've attempted similar things and sometimes found it very hard, if not impossible, to implement because of processor architecture/language assumption issues. By that, I mean the nature of the interrupts which may/may not be enabled and what use the rest of the system wants to make of them. The problem is not necessarily one of being able to get there, but getting there without severe time penalties. > To bring this discussion back on topic, probably the best solution > for compilers that want to interface cleanly with Java, is to provide an > Interfaces.Java package, with an explicitly non-standard integer type > that can be converted to and from an Ada integer type. > Clearly, that is what Ada did with C to support C's data types. Can you create an "Interfaces.Java" without being a compiler? I know GNAT complains if you try to extend anything that starts with "Ada." - do similar restrictions apply? MDC -- Marin David Condic Real Time & Embedded Systems, Propulsion Systems Analysis United Technologies, Pratt & Whitney, Large Military Engines M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600 ***To reply, remove "bogon" from the domain name.*** Visit my web page at: http://www.mcondic.com/