Confusion about bcom

I am running into some conceptual confusion about bcom that I wanted to document here as part of my process towards understanding Goblins.

It took me a while to realize that bcom can only be called at a tail position, as I eventually discovered a sentence mentioning it here. bcom also does not seem to work when made the tail of a promise callback. It would probably be helpful to have an error message if bcom is invoked in such an invalid situation.

It was helpful to use the second argument to bcom which I luckily also noticed on that page, but it was non-obvious and by default I expected to be able to call bcom, then return a value.

Is there any way to trigger the use of bcom after receving info from a promise callback? I am currently struggling with two objects which I want to both bcom something else, one triggered by the others’ change. Essentially, I want to ask the second object for some info, then bcom my second type of actor upon receiving the result in the callback. This seems like a simple operation so it is surprising to me how difficult it has been to conceptualize properly.

Stumbled upon this Imperative bcom (with backwards compatiblility with functional api) (#53) · Issues · spritely / Goblins - Guile implementation · GitLab which seems to be discussing this stumbling block! Nice to know there’s some knowledge of it.

1 Like

I have, at least for this scenario, worked around the issue by having the second object send a second message to the first, to tell it to transition to the new state (and if it cannot do so, it returns a symbol 'connecting to let the second object know something’s off). This way operations happen outside of promises and bcom can be used.

1 Like