tact icon indicating copy to clipboard operation
tact copied to clipboard

Nested maps

Open anton-trunov opened this issue 1 year ago • 4 comments
trafficstars

Tact could provide native support for nested maps with fixed arity of type like this:

m: map<(K1, K2, ... Kn), V>

To access a value, the user would need to provide a n-tuple of keys:

m.get(k1, k2, ..., kn): V?

and the same for .set, .exists, and .del.

With this feature it would make sense to support more key map types, not just Int and Address as we do now.

anton-trunov avatar Sep 24 '24 15:09 anton-trunov

why do you call it "nested maps" if it's just a map with a key being tuple?

Gusarich avatar Sep 25 '24 15:09 Gusarich

why do you call it "nested maps" if it's just a map with a key being tuple?

ah, this is because nested maps are like curried functions which are isomorphic to uncurried ones (the analogy isn't complete, though)

anton-trunov avatar Sep 25 '24 16:09 anton-trunov

In many cases people actually want maps of arity more than 1, instead of "nested maps"

anton-trunov avatar Sep 25 '24 16:09 anton-trunov

In many cases people actually want maps of arity more than 1, instead of "nested maps"

"n-key" maps can be a better term then, where regular ones are "1-key maps" (or "single-key maps")

novusnota avatar Sep 25 '24 16:09 novusnota