var item = someArray[index];
/* do something with item, and/or index */
[:item :index | "do something with item and index"].
Other points that occurred to me as I was working:
- Smalltalk’s uniform, integrated development tools (including automated refactorings and an excellent object explorer) helped keep the code clean and object-oriented.
- The built-in SUnit test runner let me develop unit tests alongside the code.
The end result of a couple of hours’ hacking is an implementation of Hunt-McIlroy text diff (that works over arbitrary SequenceableCollections, and has room for alternative diff implementations) and a diff3 merge engine, with a few unit tests. You can read a fileout of the code, or use Monticello to load the DiffMerge module from my public Monticello repository. [Update: Use the DiffMerge Monticello repository on SqueakSource.]
If Monticello didn’t already exist, it’d be a very straightforward matter indeed to build a DVCS for Smalltalk from here. I wonder if Spoon could use something along these lines?
It also occurred to me it’d be a great thing to use OMeta/JS [old link: http://jarrett.cs.ucla.edu/ometa-js] to support the use of
<script type="text/smalltalk">"<![CDATA[" (document getElementById: 'someId') innerHTML: '<p>Hello, world!</p>' "]]>"</script>