Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/What is the motivation for the new Daml interface feature?Forum ↗

What is the motivation for the new Daml interface feature?

App Development4 posts316 views7 likesLast activity May 2022
GY
gyorgybalazsiOP
May 2022

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

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

ST
stefanobaghino-da
May 2022

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.

RE
Remy
May 2022

@ 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.

CO
cocreature
May 2022

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.

← Back to Discussions