[Newbies] adding methods to a class at runtime

Mark Volkmann mark at ociweb.com
Tue Aug 14 01:58:18 UTC 2007


OmniBrowser looks interesting. I haven't installed anything new in my  
Squeak image yet. I'm guessing I just need to download the .st file  
for OmniBrowser and do a fileIn on it. Is there anything else I need  
to do to make it available in my image?

On Aug 13, 2007, at 10:37 AM, David Mitchell wrote:

> Sure, but Smalltalkers wouldn't wait for the first run of the program
> to create the accessors. And, unlike Ruby, once you ran the create
> accessor code, the accessors would be part of the code that goes under
> version control.
>
> This is one of the big differences between Ruby and Smalltalk. In
> Smalltalk, there isn't much distinction between runtime and edit time.
> Technically, there isn't any distinction. Even when you are editing
> code, you are in some sense running the eventual application.
>
> In fact, Smalltalkers often keep their application running as they  
> make changes.
>
> Take a look at:
> CreateAccessorsForVariableRefactoring
>
> Which you can invoke by right clicking on a class in the OmniBrowser
> and choosing "accessors for instvar".
>
> No reason you couldn't invoke such code at "runtime".
>
> On 8/13/07, Mark Volkmann <mark at ociweb.com> wrote:
>> Is it possible to write code that adds methods to a class at  
>> runtime. In
>> particular I'm thinking about something like attr_accessor in Ruby  
>> which
>> adds get and set methods for instance variables so you don't have  
>> to write
>> them.

---
Mark Volkmann




More information about the Beginners mailing list