Today

For the last 3 hours I’ve been thinking about this:

X = Struct.new(:id, :state, :proc) {
  def initialize(id, state=nil, &bl)
    @id, @state, @proc = id, state, bl
    super
  end

  def call = ( @proc.call if @proc )
  def scope = ( binding )
  # bad rescue
  def method_missing(name) = ( eval name.to_s, state rescue nil )
}



cat = 'Loke'


x = X.new(:apa, binding) { puts 'koko is a %s' % cat }


p x.id # => :apa

# scope
p x.cat  # => "Loke"
x.() # => Koko is a Loke

y = X.new :koko, x.scope
p y.cat # => "Loke"

It’s not the fruits of 3 hours entirely.. I’ve also had to check and feed the furnace; the washing-machine and the dryer; checking some “news”, mail and drinking beer.