bloom-lang / bud

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

Referencing a collection's schema in a rule body introduces a dependency on that collection #307

Closed JoshRosen closed 11 years ago

JoshRosen commented 11 years ago

Consider this program:

require 'rubygems'
require 'bud'

class MyMod
  include Bud

  state do
    table :mytable, [:key1] => [:val1]
    table :myothertable, [:to, :from] + mytable.key_cols => mytable.val_cols
  end

  bloom do
    mytable <= myothertable {|m| mytable.schema.map{|c| k.send(c)}}
  end

end

a = MyMod.new

This pattern might occur when we want to add additional headers to a message then strip them off later. Even though mytable appears in both the LHS and body of a <= rule, this program should be stratifiable: the collection's schema is a constant, so referencing it in a rule body shouldn't introduce a dependency on that collection.

Running this program results in an "unstratifable program" error:

/usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/bud-0.9.7/lib/bud/bud_meta.rb:221:in `calc_stratum': unstratifiable program: mytable (Bud::CompileError)
JoshRosen commented 11 years ago

Actually, never mind about the mytable.schema.map{|c| k.send(c)} example; I saw this fragment in some old Bud code, but this pattern won't work with recent versions. Absent this, I don't have another use case for reading the schema in the RHS of a rule, so you can probably close this issue.