> How might I add some instance variables to an existing class, such
> as String, and have them initialized properly?

Two possibilities come to mind immediately:

class String
	attr_writer :pos
	def pos
		@pos = 0 if not instance_variables.include? "@pos"
		@pos
	end
end

OR...

class String
	attr_writer :pos
	def pos
		@pos = 0
		class << self
			alias_method :pos, :_pos
		end
		@pos
	end
	def _pos ; @pos ; end
end

That does depend on you always using the accessor, however.

-mental