Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!usenet.eel.ufl.edu!gatech!swrinde!pipex!bnr.co.uk!bcarh8ac.bnr.ca!bcarh189.bnr.ca!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: Adding methods with method code in Smalltalk/V for Win32?
X-Nntp-Posting-Host: superior.carleton.ca
Message-ID: <D7MLCG.Cz9@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <m-rd0107.798661334@elliemae> <3njcre$6ht@tppnews.tpp.com>
Date: Wed, 26 Apr 1995 04:48:15 GMT
Lines: 49

In article <3njcre$6ht@tppnews.tpp.com>,
Bob DuCharme <bducharme@riatax.com> wrote:
>m-rd0107@cs.nyu.edu (Robert Ducharme) wrote:
>
>>If I have a class Foo with the attribute fooAttr and I want to add the
>>methods
>
>>   fooAttr
>>      ^fooAttr
>>and
>
>>   fooAttr: aString
>>      fooAttr := aString
>
>>I know how to do it by pulling down a menu, but how can I do it within
>>the code of some other object's method?
>
>If anyone's interested, I found out:
>
>	Foo compile: 'fooAttr ^fooAttr'.
>	Foo compile: 'fooAttr: aString fooAttr := aString'
>
>The browser can't then access the source code, but the methods
>function. 
>

If you want to be able to access the source code, try this way:

| stream |
stream := ReadWriteStream on: (String new: 20).
stream
    nextPutAll: '! Foo methods !';cr;
    nextPutAll: 'fooAttr'; cr;
    tab;nextPutAll: '^fooAttr!';cr;
    nextPutAll: 'fooAttr: aString';cr';
    tab;nextPutAll: 'fooAttr := aString! !';cr;
    reset;
    fileIn


David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|

