Newsgroups: comp.lang.smalltalk Path: utzoo!utgpu!cunews!knight From: knight@mrco.carleton.ca (Alan Knight) Subject: Re: Access methods - New feature ? Message-ID: <1991Apr22.130452.6181@ccs.carleton.ca> Summary: Can be done Keywords: Access methods, Smalltalk-80 Sender: news@ccs.carleton.ca (news) Organization: Carleton University, Ottawa, Canada References: <1991Apr21.221149.8057@vuse.vanderbilt.edu> <1991Apr22.003659.18658@ux1.cso.uiuc.edu> <2270@media03.UUCP> Date: Mon, 22 Apr 1991 13:04:52 GMT In article <2270@media03.UUCP> pkr@media03.UUCP (Peter Kriens) writes: >Dan Walkowski writes: >> If access methods were automatically generated for every private variable, >> then this breaks down; every object can diddle with the state of every other. >> Yes, frequently you need to write several access methods for several private >> variables of an object, but if you are finding that you need to make ALL of >Eiffel has a very nice solution for this. It allows an instance variable >to be exported in the header (Smalltalk could also do that in the >class definition, you could for example place a colon behinde the >definition of the instance variable). So in Eiffel you can easely access those often >used instance variables. The good thing is that if you decide later on >to replace the instance access with a procedure, because the implementation >changes, nobody notices because the syntax stays the same. Sounds like >a feature I could love in Smalltalk. Unfortunately you cannot access the >compiler in Digitalk smalltalk, otherwise it could be done. > >Peter Kriens >pkr@media01 A nearly equivalent feature, and one which preserves a little more encapsulation than automatically writing all acces methods is to allow them to be written on command, one at a time. i.e. have a menu item which writes access methods for a single instance variable. I've seen this done in Smalltalk/V, and it could easily be done in Smalltalk-80. The disadvantage of this method is that it discourages comments, particularly a problem in /V where there are no class comments. Coming across the automatically written message glorch: aValue "Set the value of the instance variable glorch to aValue" glorch := aValue. is annoying (to say the least), when there is no indication what kind of a thing glorch is or what it is used for. -- -- Alan Knight knight@mrco.carleton.ca +1 613 788 5783 Support Dept. of Mechanical and Aeronautical Engineering the Carleton University, Ottawa, Ontario, Canada, K1S 5B6 LPF