Question regarding true use cases for the 2 different syntaxes for writing choices

G-d willing

Hello,
I am struggling to understand the real differences between the 2 different ways a choice can be written, as I saw here:
https://docs.daml.com/daml/reference/choices.html

Can someone please provide a real use case scenario which you need/better to use one syntax over the other?

Another question around this is topic is why should I use the choice syntax before controller in the first place? I am asking that since, assuming that the controller that is registered to exercise the choice is not an observer in the template, this will cause the code not to compile, so why allowing that from the first place.

Thanks,

Hi @cohen.avraham, take a look at What's the difference between controller first and choice first? for the differences as well as a link to a blogpost that shows some examples of where they matter.

I recommend to always stick with the choice first syntax. The controller … can syntax will be deprecated in the next release.

As for your second question, this will definitely not cause a compile error. It can cause a runtime error if the contract is not visible to you. However, being an observer is not the only reason why a contract might be visible to you. You can observe it via divulgence or more likely, you might be using a multi-party submission with a party in readAs that can see the contract but is different from the controller

1 Like

Thank you very much :+1: