# Odd behavior of "key" keyword

**URL:** <https://forum.canton.network/t/odd-behavior-of-key-keyword/4523>\
**Category:** App Development\
**Created:** [May 13, 2022, 5:31pm UTC](https://forum.canton.network/t/odd-behavior-of-key-keyword/4523 "2022-05-13T17:31:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonid\_Rozenberg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/leonid_rozenberg/32/48_2.png) [@Leonid\_Rozenberg](https://forum.canton.network/u/Leonid_Rozenberg)\
**Post date:** [May 13, 2022, 5:31pm UTC](https://forum.canton.network/t/odd-behavior-of-key-keyword/4523/1 "2022-05-13T17:31:38Z")

</div>

I just noticed an odd behavior…

Why is it that in the body of a template `key` is a function to get the key, but in the maintainer field it is the key?

That does feel like a right natural behavior, but now that I’ve noticed it. It does feel odd.

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [May 13, 2022, 5:45pm UTC](https://forum.canton.network/t/odd-behavior-of-key-keyword/4523/2 "2022-05-13T17:45:21Z")

</div>

The maintainers need to be a function `Key -> [Party]` independent of the rest of the template (otherwise you could not compute maintainers for negative lookups).

So somehow we need to let users define that function. We could explicitly ask for a lambda `maintainer \key -> …` but we’ve chosen to bring the key in scope as a variable similar to how you don’t define `signatory \this@T{..} -> …` but `this` and the template fields are implicitly in scope.

Which leaves the question under what name do you bring it in scope? `key` seems like the obvious choice here so we’ve gone with that. So within the `maintainer` definition the local `key` variable simply shadows the top level `key : HasKey t k => t -> k` function. It is somewhat similar to how it’s relatively common to bring in record field values in scope via their names using record wildcards which then shadow the top-level record selectors.
