Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!swrinde!cs.utexas.edu!utnut!info.physics.utoronto.ca!ie.utoronto.ca!news
From: Gene Golovchinsky <golovch>
Subject: Re: "Private" methods
X-Nntp-Posting-Host: anarch.ie
Content-Type: text/plain; charset=iso-8859-1
Message-ID: <D9Gn3p.AFs.0.ie@ie.utoronto.ca>
Sender: news@ie.utoronto.ca (USENET News Administrator)
Content-Transfer-Encoding: 7bit
Organization: Dept. Of Industrial Engineering, University Of Toronto
References: <3qga8f$d2t@pipe6.nyc.pipeline.com>
Mime-Version: 1.0
Date: Wed, 31 May 1995 20:47:48 GMT
X-Mailer: Mozilla 1.1b3 (X11; I; SunOS 4.1.3_U1 sun4m)
X-Url: news:3qga8f$d2t@pipe6.nyc.pipeline.com
Lines: 35

mzr@nyc.pipeline.com (Moshe Rubak) wrote:
>Hi, 
> 
>I have noticed that some people find the lack of "private" (C++
>terminology) methods in Smalltalk,  to be somewhat of a shortcoming. 
>With the "sender" method in Object, it is pretty 
>easy to implement such a construct. 
>e.g. : 
>---------------------------------------------------------- 
>rows: integer 
>    "private - set number of rows" 
> 
>    (self sender class = self class) | 
>    (self sender = self class) 
>        ifFalse: 
>            [Error signal: 'private method -  Not to be used outside
>class']. 
> 
>    rows := integer. 
>------------------------------------------------------- 
> 
>I am a new-comer to the language ( one year) 
>so please, bear with me, if such solution is already known. 

You've got to check for #isKindOf: rather than class equality
because instances of subclasses have to be able to send these 
messages.

 2
G

-- 
<a href="http://anarch.ie.utoronto.ca/people/golovch/">Gene Golovchinsky</a>
University of Toronto

