Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!luvthang.UUCP!talmage From: talmage@luvthang.UUCP (David W. Talmage) Newsgroups: comp.lang.icon Subject: Idol gotcha: mixing procedures and methods Message-ID: <9105312217.AA02235@luvthang.UUCP> Date: 31 May 91 22:17:07 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 40 Boy, do I feel dumb! Here's a "gotcha" for those of us who work with Idol, Clint Jeffery's neato object-oriented language derived from Icon. In Idol, you can have both procedures and methods in a class definition. Procedures become part of the global name space while methods stay local to the objects of their class. Because procedures are in the global space, they have no concept of the variable "self", which all methods may use to access the instance variables of their class. Procedures which try to dereference self invoke a run-time error: "record expected". This sample should illustrate the problem: class DoNuthin(theFrobotz, theZimZam) method asString() return "theFrobotz= " || self.theFrobotz || " theZimZam= " || self.theZimZam end procedure printThem() write( self.theFrobotz ) write( self.theZimZam ) end initially printThem() end procedure main() local aDoNuthin aDoNuthin := DoNuthin( "David", "Talmage" ) write( aDoNuthin$asString() ) end I don't want to tell you how long it took me to figure that one out. ----------------------------------------------------------------------------- David W. Talmage (talmage@luvthang.aquin.ori-cal.com) "I need fifty dollars to make you hollar. I get paid to run this luvthang."