Skip to content

[Feature] Nicer syntax for querying mappings dynamically #29294

@AleoAlexander

Description

@AleoAlexander

🚀 Feature

Dynamic dispatch allows calling functions from a callee determined at runtime, while still allowing static calls

// Static (allowed)
target.aleo::method(args)

// Dynamic (allowed)
Interface@(target)::method(args)

However, interfaces can also define mappings. Currently though, the intuitive syntax for reading from mappings dynamically is not supported:

// Static (allowed)
target.aleo::mapping_name.get(key)

// Dynamic (NOT allowed)
Interface@(target)::mapping_name.get(key)

We should also support reading from storage types dynamically

// Static (allowed)
target.aleo::variable_name.unwrap_or(0u64);
target.aleo::vector_name.get(0u32);
target.aleo::vector_name.len();

// Dynamic (NOT allowed)
Interface@(target)::variable_name.unwrap_or(0u64);
Interface@(target)::vector_name.get(0u32);
Interface@(target)::vector_name.len();

Updated: 4/3/26, 12:09 ET

Metadata

Metadata

Assignees

Labels

🚀 featureA new feature.🧱 Core CompilerAnything related to the core compiler including parsing, analysis, transforms, codegen, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions