Path: utzoo!censor!comspec!lethe!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!clyde.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!udel!princeton!cs!hart!nr From: nr@hart.Princeton.EDU (Norman Ramsey) Newsgroups: comp.lang.modula3 Subject: Specializing objects Message-ID: <6929@rossignol.Princeton.EDU> Date: 14 Feb 91 21:02:31 GMT Sender: news@cs.Princeton.EDU Organization: Dept. of Computer Science, Princeton University Lines: 27 Suppose I have two object types TYPE T = OBJECT mumble, fritz: INTEGER; END; TA = T OBJECT a: BOOLEAN; END; and suppose further that I am handed a T and want to produce a TA with the property that every field of the TA has the same value it had in the T. I can't think of anything any better than: PROCEDURE Narrow(o:T):TA = BEGIN RETURN NEW(TA, mumble := o.mumble, fritz := o.fritz, a := ); END Narrow; Is there some way for me to do this without having to enumerate all the fields of T? If not, I am bound to break my programs by extending T and forgetting to update Narrow. -- Norman Ramsey nr@princeton.edu