-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
new-builtinThe issue describes a new Clarity builtin (function or variable)The issue describes a new Clarity builtin (function or variable)
Description
I suggest the introduction of a new top-level built-in like use-trait.
The use-function built-in is used to import and alias a function of another contract.
contract-a:
(define-data-var some-var uint u0)
(define-public (some-func (some-param uint))
(ok (var-set some-var some-param))
)contract-b:
(use-function SP123...contract-a some-func my-some-func)
(define-public (use-some-func)
(my-some-func u42)
)The calling context remains the contract the function is defined in. Using my-some-func would be equivalent to substituting it with contract-call?. (It is a call, not a delegate call.)
use-function, like use-trait, can only be used top-level.
The upsides:
- All contracts for which
use-functionis used are cached so the external function will be cheaper to call iteratively compared to a series ofcontract-call?. It is an alternative solution for the issue described in Support caching model #94. Bound by all the same runtime dimensions. - Much easier to create library contracts that add functionality.
- Better composability, don't need to repeat
contract-call?nor create a local wrapper function.
Edit: related to #11.
friedgerfriedger
Metadata
Metadata
Assignees
Labels
new-builtinThe issue describes a new Clarity builtin (function or variable)The issue describes a new Clarity builtin (function or variable)