An addendum to my note from earlier today: the constructor problem is more annoying than I’d thought, because (as I just discovered!) the static constructor method is harder to carry out than I’d realized. After all, the static constructor method still has to create an object of the type in question, which means that it has to (indirectly) call that object’s
initialize method. (Well, it probably doesn’t have to, this being Ruby, but that’s another matter.) Which, in turn, means that the
initialize method has to allow you to set up the state in a sufficiently general way to make that easy for your static method. And that means that it probably has to expose your object’s internal state pretty directly. But that may not be the way that you want other users to construct your objects, putting you in a bit of a bind.
I’m pretty sure I don’t yet understand all the options and tradeoffs here. I’ll have to do a bit more reading and thinking, I guess. (And then probably ask on the newsgroup.)
There are no revisions for this post.