What is the motivation for the new Daml interface feature?

https://docs.daml.com/daml/reference/interfaces.html

Can you show me a real-life example when this is useful?

Daml currently doesn’t allow templates to depend on code that hasn’t been written yet. So it’s impossible to write something like a generic swap that also works for asset templates that are added later. This is about adding a language feature which enables the writing of such “generic” templates.

3 Likes

@ gyorgybalazsi Thanks for the interrest.

The feature is still in development. Before we make it stable (hopefully soon), we will update our document with examples showing concrete use cases.

1 Like

Elaborating on @stefanobaghino-da’s answer: A crucial point is that this is not just static genericism at the code/template level: Interfaces allow you to have an active contract that can exercise a choice on a contract without being tied to a specific template. I usually phrase it in terms of decoupling: Without interfaces, a template statically determines all other templates it interacts with. If those referenced templates change, you need to update all contracts of the template to point to those new templates. With interfaces, you can independently evolve the two.

3 Likes