在 DAML 中是否有可能有一个通用参数来选择,而模板本身不是通用的?

Is it possible in DAML to have a generic parameter to a choice, without the template itself being generic?

在我的模型中,我试图定义一个非通用模板,该模板可以选择采用通用参数。我不知道该怎么做。有可能吗?如果不是,为什么?

这是不可能的,而且是故意的。 DAML 的设计原则之一是,当你签署合同时,你就清楚地知道你同意的是什么。

假设资产有一个类型 class Transferrable,我发布了一个包含空类型 class Stealable 和模板 PermissionToSteal 的包:

class (Template a, Transferrable a) => Stealable a where

template PermissionToSteal
  with
    owner : Party
    thief : Party
  where
    signatory owner, thief

    controller thief can
    (Stealable a) => Steal : (ContractId a)
      with
        asset : a
      do
        transfer asset thief

我也许可以说服您签署 owner 这样的合同,因为您知道没有 Stealable.

的情况,您会感到安全

但是,如果我现在上传另一个带有 instance Stealable Cash 的包怎么办?