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?
Date: 14 Oct 92 17:03:36 GMT [thread overview]
Message-ID: <11225@platypus.uofs.uofs.edu> (raw)
In article <dnsurber.718567247@node_26400>, 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 |
+------------------------------------------------------------------+
next reply other threads:[~1992-10-14 17:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-10-14 17:03 yale.edu!jvnc.net!netnews.upenn.edu!uofs!guinness.cs.uofs.edu!beidler [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-10-15 8:50 Generic Instantiation as Subprogram Body? darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!
1992-10-08 19:54 dog.ee.lbl.gov!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!hobbes.ph
1992-10-08 18:00 Douglas N. Surber
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox