The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Extension Angst

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 Angst Posted: May 29, 2008 7:21 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Extension Angst
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

I noticed today that Travis was suffering from Extension Angst, now, he didn't say he was suffering from extension angst - that's just how I read it. What is Extension Angst anyway?

Extension Angst occurs when you decide to extend a base class in your package but it feels inappropriate because you're making an arbitrary judgement on the way you believe that base class should behave or act. In Travis's case, he wanted new conditionals for collections. I like his extensions but I also have a touch of extension angst - I can't justify them being part of Smalltalk: The Language.

How could we fix Extension Angst? Well, the angst part comes from the way extensions interact with the rest of the environment. If you load my package, any extensions I've made are now globally available to all packages. This may not be what you want to do at all - in fact, it could be detrimental to the environment. It would be nice if said methods were in fact namespaced.

So hey, why not? ObjectStudio 8 has a neat trick where by if you call a method on a class from an ObjectStudio class and the method is an ObjectStudio specific method that is incompatible with standard VisualWorks behavior - it'll rewrite the selector its sending to be a different one!

We can do the same to extension methods within a package. If you are sending #lastOr: then it could be transformed in to MyPackageNamespace_lastOr: and we could add a default implementation on Object that calls #lastOr: in case you were trying to pickup behavior from another package.

This immediately removes the scoping issue - however it also means that other packages cannot polymorphically use your extensions... but... that was kind of the point. In that case you really need to be able to specify whether a method you're calling is private to your package or not. We could do this with a pragma.

Normally I'd provide code as a proof-of-concept for this sort of blog post, but in this case I didn't feel a strong need to actually see how well this kind of idea would work. I'll leave that exercise up to the reader if they're interested.

Read: Extension Angst

Topic: Smalltalk Solutions Daily Update: Acceptance Testing Previous Topic   Next Topic Topic: In Space, no one can hear you flush

Sponsored Links



Google
  Web Artima.com   

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