bloom-lang / bud

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

calling <= from Ruby silently drops data #289

Closed jhellerstein closed 11 years ago

jhellerstein commented 11 years ago

If you call <= from Ruby outside of Bloom, it appears not to do anything. I'd prefer to say it's a semantic error (you can't interact with "now" from the exterior), but open to argument on that front.

require 'rubygems'
require 'bud'

class PingPong
  include Bud

  state do
    channel :ping, [:@to, :from, :payload]
    scratch :bootz, ping.schema
  end

  bloom do
    ping <~ bootz
    stdio <~ ping.inspected
  end
end

alice = PingPong.new(:port => 12345)
alice.run_bg
alice.bootz <= [['localhost:23456', 'localhost:12345', 0]]
alice.tick
alice.tick
neilconway commented 11 years ago

Well, <= does work as you'd expect when inserting into a persistent collection -- the problem is just that scratches are cleared at the beginning of the tick. You could possibly reject that as well, and require that users use <+ in both situations.

Note that there is not really a concept of "internal" vs. "external" insertions in Bud right now, but you could probably make one up pretty easily -- e.g., set a variable "inside_bud" at the start of tick_internal.

jhellerstein commented 11 years ago

We actually already have an @inside_tick variable in tick_internal. Working on using it as suggested.