Methods in a Smalltalk object live in the method dictionary of its class. A method dictionary maps
CompiledMethods. From the virtual machine’s perspective, anything that understands
#run:with:in is compatible with a
CompiledMethod, in the sense that the VM sends this message to things that it will execute.
As a result, it’s easy enough to put arbitrary objects (that understand
#run:with:in) in a class’s method dictionary. In fact, there’s a library for it.
With this hammer in hand, it becomes trivial to perform all manner of intercessions on code, without instrumenting code through a rewrite+compile cycle: wrap the
CompiledMethod in an
ObjectAsMethodWrapper (or several) and away you go. What might you do? Pre- and post-condition checking, flagging which methods execute for coverage analysis, profiling, and so on. Today we’re going to turn a method into a memoised one.
I’ve been learning Clojure recently, and I’d been looking around for a good initial project to test my new knowledge. I’ve always wanted to write a Befunge interpreter, and so decided that sounded like a fun project. Little did I know the maze of twisty little passages I was letting myself in for, but I’ve learnt a lot of interesting things along the way, and there’s a few things worth sharing.
Back in the dark years of 2003, Avi Bryant and Colin Putney tried to use CVS to version their Smalltalk code and failed dismally. They decided to scratch their itch, and Monticello was born, a DVCS centred around managing the structured text of Smalltalk code.
Years have passed, and nowadays we have Mercurial and Git providing succour to so many. How can Smalltalk leverage these tools, instead of maintaining its own custom version control system?
Lloyd’s asked us to take a look at the security design of a new gaming business that they had been asked to underwrite – this start-up has an interesting gaming model which has insured the payout of all wins over a certain value. For Lloyds, the maths works, but only if the software actually does what it should.
Topjack Games MD talks about how the business works.
You are currently browsing the LShift Ltd. blog archives for August, 2012.