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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e89f5b405fdfed5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-02-28 14:21:13 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!fauern!news.th-darmstadt.de!terra.wiwi.uni-frankfurt.de!zeus.rbi.informatik.uni-frankfurt.de!news.dfn.de!fu-berlin.de!zrz.TU-Berlin.DE!netmbx.de!unlisys!news.maz.net!pipex!howland.reston.ans.net!gatech!news-feed-1.peachnet.edu!paperboy.wellfleet.com!noc.near.net!inmet!henning!stt From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Using complex from interfaces.fortran. Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. X-Newsreader: TIN [version 1.1 PL8] References: <1995Feb22.164009.16834@driftwood.cray.com> Date: Tue, 28 Feb 1995 22:21:13 GMT Date: 1995-02-28T22:21:13+00:00 List-Id: Brian Hanson (brh@cray.com) wrote: : I was looking at the package Interfaces.Fortran. Suppose you want to work : with complex numbers. There is a type defined in this package called Complex : and you can do all the normal stuff with it but suppose you wish to output a : complex number. How to do it? : with Interfaces.Fortran; use Interfaces.fortran; : with ada.text_io.complex_io; : procedure test is : package complex_io is new ada.text_io.complex_io : (single_precision_complex_types); : with complex_io; ^^^^ "use" presumably : a, b, c: complex; : begin : a := (1.7, 2.8); : b := (9.5, 6.2); : c := a * b + complex'(2.3, 0.0); : put(c); : end; : My expectation is that the put not compile because it expects the type : single_precision_complex_types.complex and not the complex defined in : fortran. : Is this true. Yes, that is your problem. : ... If so, does it not make using complex from package fortran : very awkward for io and functions like sin, cos which are also accessed : via a generic package with a package parameter? Yes, this seems like an unintended consequence of making Interfaces.Fortran.Complex a derived type. A subtype would probably have been better, though that would require the user to do a "use type Interfaces.Fortran.Complex" rather than a "use Interfaces.Fortran" to get direct visibility to the operators (not so terrible IMHO). Oh well, you can't win them all. In any case, you can work around the problem in two ways. One, insert an explicit conversion in the call on "Put", e.g.: Put(Single_Precision_Complex_Types.Complex(C)); or two, avoid use of Interfaces.Fortran.Complex and instead use Interfaces.Fortran.Single_Precision_Complex_Types.Complex directly. In the latter case, you might want to locally declare "Complex" to be a subtype of Single_Precision_Complex_Types.Complex and then do a "use type Complex;" : -- Brian Hanson : -- brh@cray.com : ps. I attempted to try this with gnat 2.03 but got compile errors for : the package instantiation. So I do not know if it is gnat that is wrong : or my program that is wrong. The instantiation looks OK. GNAT might not fully support formal package parameters yet; send a report to gnat-report to find out for sure. -Tucker Taft stt@inmet.com