bloom-lang / bud

Prototype Bud runtime (Bloom Under Development)
http://bloom-lang.net
Other
854 stars 59 forks source link

tables don't drive lattice deltas, but frame-ruled scratches do #290

Closed jhellerstein closed 11 years ago

jhellerstein commented 11 years ago

The following code behaves as you would expect:

require 'rubygems'
require 'bud'

class Phooey
  include Bud
  state do
    lmax :cloq
    scratch :truth, []=>[:val]
  end

  bootstrap do
    truth <+ [[true]]
    cloq <+ Bud::MaxLattice.new(0)
  end

  bloom do
    # frame rule for truth    
    truth <+ truth

    # A process increments its counter before each event in that process;
    cloq <+ truth {|t| cloq + 1}
    stdio <~ truth {|t| [cloq.inspect]}.inspected
  end
end

p = Phooey.new
p.tick
p.tick
p.tick

But when you replace the scratch and frame rule with a table, it's as if it only ticks once!

require 'rubygems'
require 'bud'

class Phooey
  include Bud
  state do
    lmax :cloq
    table :truth, []=>[:val]
  end

  bootstrap do
    truth <+ [[true]]
    cloq <+ Bud::MaxLattice.new(0)
  end

  bloom do
    # A process increments its counter before each event in that process;
    cloq <+ truth {|t| cloq + 1}
    stdio <~ truth {|t| [cloq.inspect]}.inspected
  end
end

p = Phooey.new
p.tick
p.tick
p.tick