This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: How Valuable is a Symbol?
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
A week's journey through some extensions to the base. There are more. We could go on for a while, but I'll give it a rest (at least until I hit a week where I can't come up with anything). I thought it would be fitting at the close to submit "The Simplest Little Extension that Could Possibly make a Big Difference." Here's the code:
Symbol "i'd put those standard 2x greater than things in here, but that doesn't seem to work"
value: anObject
^anObject perform: self
That's it. That's all there is. I didn't even write any tests. Nor can I take any credit. I was clued into this one by Brant and Roberts (of Refactoring Browser fame) who told me they got it from Ward Cunningham (of Wiki fame). If it has more lineage than that, I'd love to here it.
I love this extension (and I've lauded its wonderfulness on many occasions), because it has the ability to affect so much, with so few characters. What the extension does is allow to replace just about any thing that looks like:
[:each | each unaryMessage]
with
#unaryMessage
There is a tendency to look at this and say that sounds cool, but I don't think I'll use it. It's outside of the standard smalltalk language domain and I'm worried there might be some adverse effects if I use it. We've been using it in LOTS of code at Key for 3+ years now. Nothings gone wrong yet. I dare others to try it and prove me wrong. See if being able to treat collection do:/reject:/select:/collect:/anySatisfy:/allSatisfy:/detect:/ like "attribute" queries doesn't cause you to spend less time typing extra characters and worry about your problem more.
SymbolValue is a package in the Open Repository that adds this.
The five standard bundles, have 761 candidates for this kind of replacement. Want to see where you can use it in your code? Select the appropriate method(s)/protocol(s)/class(es)/package(s). Select the rewrite tab, and enter