AIP-112: Introducing Function Values in the Move VM

The recent merge of AIP-112 introduces function values to the Move Virtual Machine (Move VM), marking a significant leap in the expressiveness of the Move programming language. This enhancement brings higher-order functions, dynamic dispatch, and advanced borrow semantics with global storage into the ecosystem, promising to redefine how developers interact with on-chain logic and data.

What Does AIP-112 Enable?

  1. Higher-Order Functions and Lambda Expressions
    Move now supports higher-order functions, a feature familiar to modern programming languages. Developers can leverage lambda expressions to write cleaner, more modular code by embedding declarative abstractions directly into their contracts. This change simplifies the logic by allowing function values to be passed as arguments, stored in structures, and even persisted in global storage.
  2. Separation of Storage and Logic
    The update enhances Move’s ability to separate storage management from application logic. Modules that own global storage can define policies while enabling other modules to work with the stored data seamlessly. For example, developers can now pass a closure to manage data within a resource, eliminating prior constraints imposed by inline functions.
  3. Storable Function Values
    With function values that can be stored on-chain, AIP-112 unlocks the ability to create dispatch tables. This is especially valuable for DeFi applications, as it enables flexible and scalable asset management without hardcoding dependencies. For instance, contracts can register new assets with custom processing logic, all while reducing the need for redeployment or static linking.
  4. Dynamic Dispatch with Safety
    Dynamic dispatch is introduced without compromising the integrity of Move’s strict borrow semantics. Reentrancy checks ensure that storage access remains safe even during indirect calls, maintaining Move’s high standards for security and predictability.

Why Does This Matter?

This feature addresses longstanding limitations in Move by:

  • Allowing flexible, reusable logic through function values.
  • Enabling complex DeFi scenarios where scalability and modularity are key.
  • Aligning Move with the capabilities of other modern programming languages while retaining its unique focus on security.

Broader Impact on DeFi and Web3

AIP-112’s support for function values positions Move as a powerful tool for Web3 developers. Particularly in DeFi, where handling diverse assets dynamically is critical, these new capabilities promise to simplify application design, reduce operational overhead, and foster innovation.

Future Potential

While AIP-112 is already transformative, future iterations could further enhance its utility by enabling mutable reference captures and private, persistent functions for more granular control.

2 Likes