bloom-lang / bud

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

introduce a Bloom way to exit process #231

Closed jhellerstein closed 12 years ago

jhellerstein commented 12 years ago

Perhaps a "die" relation?

michaelficarra commented 12 years ago

I like this idea. I would prefer the name exit.

neilconway commented 12 years ago

There can be multiple Bud interpreters inside a single process; it would probably be best to just have this facility shutdown the current interpreter rather than exit the whole process.

This also relates to the question of error handling in general.

Note that this can be accomplished easily enough by just putting side-effecting code on the RHS of a rule:

state do
  scratch :die
  scratch :dummy
end

bloom do
  dummy <= die { do_shutdown }
end

(I haven't checked that that works; presumably some variant of do_shutdown, stop_bg or similar would suffice.)

jhellerstein commented 12 years ago

thanks for feedback. resolved in 84d60a465fc26f785d9c

I agree that die is a little extreme. chose to name the distinguished predicate halt because exit was coming up as a pre-defined symbol in Bud::define_collection. The implementation simply registers a scratch called halt with a callback that invokes stop_bg. See test/tc_exit.rb:

  bloom do
    halt <= tbl{|t| t if t.key == 2}
    tbl <+ tbl{|t| [t.key+1]}
  end