Path: news.daimi.aau.dk!olevi From: olevi@daimi.aau.dk (Ole Villumsen) Newsgroups: comp.object,comp.lang.eiffel,comp.lang.sather,comp.lang.beta,comp.lang.modula3 Subject: Re: Cows, Hogs & Farms Date: 6 Jan 1995 10:12:29 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 37 Message-ID: <3ej52d$3va@belfort.daimi.aau.dk> References: <3e07c4$sup@muss.cis.McMaster.CA> <1995Jan5.183534.10065@schbbs.mot.com> NNTP-Posting-Host: angers.daimi.aau.dk Xref: news.daimi.aau.dk comp.object:23483 comp.lang.eiffel:7116 comp.lang.sather:1388 comp.lang.beta:198 comp.lang.modula3:3296 I haven't followed (nor understood) the entire discussion. But as far as I can see, Beta does not have the problem Sather is claimed to have. herbivore: (# foodType:< plant; (* virtual type *) eat: (# someFood: ^foodType; enter someFood[] do ... #); #); cow: herbivore (# foodType::< grass; (* further binding the virtual *) #); hog: herbivore (# foodType::< corn; #); Now we can go (assuming the variables are declared with the expected types: someGrass: ^grass; somePlant: ^plant; etc.): someGrass[] -> &aCow.eat; (* o.k.; typechecked at compile-time *) someGrass[] -> &aHog.eat; (* error, reported by compiler *) somePlant[] -> &aCow.eat; (* compiler will insert a runtime type check *) someCorn[] -> &aHerbivore.eat; (* again, runtime type check *) (if somePlant## // grass## then somePlant[] -> &aCow.eat; // corn## then somePlant[] -> &aHog.eat; else ... if); How's that? (The compiler will insert runtime type checks in the last example, unless you instruct it not to; maybe future versions of the compiler will be smart enough to "see" that it's not necessary.) Ole