Path: news.daimi.aau.dk!news.uni-c.dk!sunic!trane.uninett.no!eunet.no!nuug!EU.net!howland.reston.ans.net!darwin.sura.net!wvnvms!marshall.wvnet.edu!marshall.edu!hathawa2 Newsgroups: comp.object,comp.lang.eiffel,comp.lang.sather,comp.lang.beta,comp.lang.modula3 Subject: Re: Cows, Hogs & Farms Message-ID: <1995Jan9.005627@hobbit> From: hathawa2@marshall.edu (Mark S. Hathaway) Date: 9 Jan 95 00:56:27 EDT References: <3eih36$94g@network.ucsd.edu> <1995Jan6.164948.4782@schbbs.mot.com> Organization: Marshall University Nntp-Posting-Host: frodo.marshall.edu Lines: 127 Xref: news.daimi.aau.dk comp.object:23563 comp.lang.eiffel:7127 comp.lang.sather:1396 comp.lang.beta:204 comp.lang.modula3:3307 > In article <1995Jan6.164948.4782@schbbs.mot.com>, > shang@corp.mot.com (David L. Shang) writes: >> In article <3eih36$94g@network.ucsd.edu> >> mbk@inls1.ucsd.edu (Matt Kennel) writes: >> ... >> You can do most of Cluster's static solution in Sather, and I guess Eiffel. >> >> ... >> class MONOCULTUREFARM{FOODT, ANIMALT < $HERBIVORE{FOODT} } is >> attr livestock : LIST{ANIMALT}; -- type is known at compile time >> attr foodstock : LIST{FOODT}; -- type is known >> ... Should there be a $FOOD abstract type used here ( "FOODT < $FOOD" )? Would there have to be an "include HERBIVORE" and maybe "include FOOD" for this to work? How would that be done? > This form is slightly different in semantics from the Cluster's form: > > class MONOCULTUREFARM [ANIMALT <: HERBIVORE] > attr livestock : list[ANIMALT]; > attr foodstock : list[ANIMALT.FOODT]; > ----- (1) Does Cluster separate the subtyping and inheritance as Sather does? Is the use of "ANIMALT <: HERBIVORE" a convenience or requirement? So, ANIMALT.FOODT implies that a particular food is associated with a particular animal? How can it be a HERBIVORE and yet eat only one kind of plant? > or BETA's form: > > MONOCULTUREFARM > (# ANIMALT :< HERBIVORE > attr livestock : @list (# eleT::ANIMALT #); > attr foodstock : @list (# eleT::ANIMALT.FOODT #); > #) It's not especially readable, is it? Is it really ":<" rather than Cluster's "<:"? Very funny contrarianism! Since "ANIMALT :< HERBIVORE" is inside the "(#" & "#)" enclosure I wouldn't guess you could create a MONOCULTUREFARM(COW). Since there's no "class" in front of "MONOCULTUREFARM" I'd guess that everything in BETA is a class or pattern or somethin', huh? So, by having only one "form" it can be understood what this is. Is there any special notation to differentiate a main program from these others? Do any of these MONOCULTUREFARMs (Sather, Cluster or BETA) inherit from FARM or are they the lowest base of farm that will exist in this class hierarchy? [snipped a bunch] > It might be difficult to argue which way is better for a farm, but as I > said, the language should at least give the way that the speaker wants. Yes, the language should provide a way to express something. That's why I cringe when I see syntax like BETA's. :-) How about... class MonocultureFarm ( food is plant, animal is herbivore ) is procedure feed (); end MonocultureFarm; class MonocultureFarm body is import list; object livestock is list(animal); foodstock is list(food); procedure feed ( get livestock is in out list(animal); get foodstock is in out list(food) ) is begin ... end feed; end MonocultureFarm; program temp is import MonocultureFarm; object myfarm is MonocultureFarm(corn,hog); begin myfarm.feed(); end temp. Since it's not like a procedure within a module the parameters of MonocultureFarm which are of type/class plant and herbivore aren't "import"ed first. That's a little awkward, but these other languages (BETA, Cluster, Sather) don't seem to need the "import". Is it no longer regarded as necessary? > Back to the major differece: > > Cluster's generic class are real classes but Sather's is not. > Therefore, by Cluster, HERBIVORE[GRASS] is a subclass/subtype > of HERBIVORE. I hesitate to ask what kind of GRASS is an HERBIVORE. > By Sather, HERBIVORE[GRASS] cannot be a subclass/subtype of HERBIVORE. > That's whay Sather cannot have the expression: > > ANIMALT < $HERBIVORE > > because HERBIVORE is not a class. I asked (above) if Sather would also have to use an "include HERBIVORE" to comlete the equation. This comparison of Cluster's inheritance scheme to Sather's asks the same question. If you're inheriting an HERBIVORE then how can it be an HERBIVORE that only eats GRASS? It seems to me that the tying together of the specific food(s) to the animal has to be done at a higher level of abstraction -- probably in the algorithm which represents the farmer's actions. You can put a COW in a field of several plants, but you can't force it to eat only GRASS. A HERBIVORE COW might choose to eat clover. :-) Mark S. Hathaway