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=2.9 required=5.0 tests=BAYES_50,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: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: fdb77,953e1a6689d791f6 X-Google-Attributes: gidfdb77,public X-Google-Thread: 1108a1,953e1a6689d791f6 X-Google-Attributes: gid1108a1,public X-Google-Thread: f79bb,953e1a6689d791f6 X-Google-Attributes: gidf79bb,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: mbk@caffeine.engr.utk.edu (Matt Kennel) Subject: Re: Eiffel and Java Date: 1996/11/05 Message-ID: <55nvo4$mgk@gaia.ns.utk.edu>#1/1 X-Deja-AN: 194668370 references: <55ditr$pnh@gaia.ns.utk.edu> <1996Nov4.140227.4601@schbbs.mot.com> followup-to: comp.lang.eiffel,comp.lang.ada,comp.lang.sather,comp.lang.java.advocacy,comp.object organization: University of Tennessee, Knoxville and Oak Ridge National Laboratory reply-to: %%spam repellent: remove this prefix%%kennel@msr.epm.ornl.gov newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.sather,comp.lang.java.advocacy,comp.object Date: 1996-11-05T00:00:00+00:00 List-Id: David L. Shang (shang@corp.mot.com) wrote: : In article <55ditr$pnh@gaia.ns.utk.edu> mbk@caffeine.engr.utk.edu (Matt Kennel) : writes: : > David L. Shang (shang@corp.mot.com) wrote: : > : But Sather's superclass construction is limited to non-parametrerized : > : classes only. : > : > This isn't true, at least in 1.1. The following compiles and executes. : > : > ------------------------------------------------------- : > -- demonstrate abstract superclass over a parameterized type. : > ------------------------------------------------------- : > abstract class $OVER{T} > $P{T} is : > feature1(arg:T); : > end; : > : > abstract class $P{T} is : > feature1(arg:T); : > feature2(arg:T); : > end; : > : > class CONCRETE{T} < $OVER{T} is : > feature1(arg:T) is #OUT + "In feature\n"; end; : > create:SAME is return new; end; : > end; : > : > : > class MAIN is : > main is : > #OUT + "Hello World.\n"; : > : > ob :$OVER{INT} := #CONCRETE{INT}; : > ob.feature1(42); : > : > end; : > end; : > : Try the following, if Sather's compiler does not complain, then, : Sather's generic class is equivalent to Transframe's: : class MAIN is : main is : #OUT + "Hello World.\n"; : : ob :$OVER; : if (some_input_condition) ob := #CONCRETE{INT}; : else ob = #P(STRING); : : // at this point, we don't know the exact element type of ob : // type assurance must be used : assume (typeof(ob).ElementType is INT) ob.feature1(42); : end; I don't think the generic class concept is the same, but the following appears to do what you desire. The main difference is that in Sather $TYPE{T} and $TYPE are wholly unrelated _a priori_. $TYPE is not a superytpe of $TYPE{T} unless explicitly declared that way, as in this example. --------------------- abstract class $OVER is -- over everything end; abstract class $OVER{T} < $OVER > $P{T} is feature1(arg:T); end; abstract class $P{T} is feature1(arg:T); feature2(arg:T); end; class CONCRETE{T} < $OVER{T} is feature1(arg:T) is #OUT + "In feature\n"; end; create:SAME is return new; end; end; class MAIN is main(args:ARRAY{STR}) is #OUT + "Hello World.\n"; ob :$OVER; if args[1] = "int" then #OUT + "Creating int\n"; ob := #CONCRETE{INT}; else ob := #CONCRETE{STR}; end; typecase ob when $OVER{INT} then ob.feature1(42); else #OUT + "No matching typecase\n"; end; end; end; ------- (~/sather1/hello) caffeine.engr.utk.edu > a.out int Hello World. Creating int In feature (~/sather1/hello) caffeine.engr.utk.edu > a.out other Hello World. No matching typecase (~/sather1/hello) caffeine.engr.utk.edu > ------- : > : Transframe provides a more powerful superclass construction that : > : can support parameterized classes. : > : > : Suppose we have two existing classes : > : .... : > : > I believe that Sather could express the same concept. : > : The concept of generic class in Sather is different than Transframe's. : David Shang -- Matthew B. Kennel/mbk@caffeine.engr.utk.edu/I do not speak for ORNL, DOE or UT Oak Ridge National Laboratory/University of Tennessee, Knoxville, TN USA/ I would not, could not SAVE ON PHONE, |================================== I would not, could not BUY YOUR LOAN, |The US Government does not like I would not, could not MAKE MONEY FAST, |spam either. It is ILLEGAL! I would not, could not SEND NO CA$H, |USC Title 47, section 227 I would not, could not SEE YOUR SITE, |p (b)(1)(C) www.law.cornell.edu/ I would not, could not EAT VEG-I-MITE, | /uscode/47/227.html I do *not* *like* GREEN CARDS AND SPAM! |================================== M A D - I - A M!