The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Extension Methods

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Extension Methods Posted: Jan 14, 2008 4:08 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Extension Methods
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

In the comments for this post, I got an honest question about adding "extension methods" in Smalltalk. This was in the context of an overly excited C# developer noticing the limited version of this that Microsoft provides.

In Smalltalk, we don't really have a name for doing this, because it's something natural. We've always been able to add and/or modify methods at runtime. Heck, we can add or modify existing classes at runtime - over the weekend, I modified classes in the blog server you're reading this on. In Smalltalk, there's not really a line between "development time" and "tuintime".

With Smalltalk, you can add methods, modify existing method definitions, delete methods, add new classes, modify existing class definitions, and delete existing classes at runtime. I do that in this blog server all the time, and the people reading it don't notice, unless the modification adds new (visible) functionality). When you modify a class definition in Smalltalk, things "just work" - all the existing instances in memory get modified to match the new definition. This is why I often define accessors for new attributes like this:

 

foobar
     "get the foobar instance variable"

      ^foobar ifNil: [foobar := 0].

That way, it gets initialized the first time it gets requested. I could just as easily send a message to all the instances (assume the class is called FooBar):


FooBar allInstances do: [:each | each foobar: 0].

With Smalltalk, you almost never have to shutdown a running service to update it. You can do that as a matter of policy, but you can also - as I do - upgrade it in place

Technorati Tags:

Read: Extension Methods

Topic: Meeting 21 - Programming Erlang Previous Topic   Next Topic Topic: Smalltalk Daily 1/11/08: Setting up Store

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use