From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 14 Oct 92 17:03:36 GMT From: yale.edu!jvnc.net!netnews.upenn.edu!uofs!guinness.cs.uofs.edu!beidler@yal e-bulldog.arpa (Jack Beidler) Subject: Re: Generic Instantiation as Subprogram Body? Message-ID: <11225@platypus.uofs.uofs.edu> List-Id: In article , dnsurber@lescsse.jsc.nasa.gov (Doug las N. Surber) writes: |> |> The following code is what I want to write. It doesn't work and I don't |> like that! |> |> generic |> type T is range <>; |> package P is |> |> type U is private; |> |> function "<" (l,r : U) return boolean; |> function "<=" (l,r : U) return boolean; |> function ">" (l,r : U) return boolean; |> function ">=" (l,r : U) return boolean; |> |> private |> . . . Since "<=" is equivalent to "not >" and ">=" is equivalent to "not <" the package spec should be generic type T is range <>; package P is type U is private; function "<" (l,r : U) return boolean; function ">" (l,r : U) return boolean; private . . . Is it "Stoopid machine!" or "Stoopid _____!" In the package body |> |> generic |> with function op(l,r : T) return boolean; |> function rel (l,r : U) return boolean; |> |> -- the following doesn't work. declared function name hides the |> -- generic actual. |> function "<" is new rel("<"); |> function "<=" is new rel("<="); |> function ">" is new rel(">"); |> function ">=" is new rel(">="); |> |> function rel (l,r : U) return boolean is |> begin |> return op(l, r); -- or whatever |> end rel; |> |> end P; since you have not shown what type "U" is, I am only guessing, but if "U" is a record or array, "<", etc. are not defined, hence "<" has no meaning for type "U". Insteaad of the contrived generic function rel, supply the bodies of the ordering functions for the type U, function "<" (l, r : U) return boolean is begin . . . end "<": -- +------------------------------------------------------------------+ | John (Jack) Beidler | | Prof. of Computer Science Internet: BEIDLER@JAGUAR.UOFS.ED | | University of Scranton beidler@guinness.cs.uofs.edu| | Scranton, PA 18510 Bitnet : BEIDLER@SCRANTON | | | | Phone: (717) 941-7446 FAX: (717) 941-4250 | +------------------------------------------------------------------+