Create a UDFunction from another UDF with a dynamic body content

Consider the following User-Defined Functions:

Query(
  Lambda(
    ["name", "word"],
    CreateFunction({ name: Var("name"), body: Query(Lambda("_", Var("word"))) })
  )
)

What it does
Given the fact that Var("word") will not be computed the created function will fail.
(The variable ‘world’ isn’t available obviously inside the created function.)

What I’ld expect
I’m sure it’s still probably some quite uncharted territory but I’d love to see this working.

But why?
For example, I use UDFs as settings store for Data Schemas. Biota’s schema module validates/parses value against a schema. Schemas are use extensively for strict validation right within Fauna and thus would not make sense to live into its own collection. Reads would go through the roof while data is static and won’t change much. UDFs is pretty nice as it can act as a static store for this use case.

So far I’ve gone around the issue but that’s not as beautiful as I’d expect it to be.

Agreed! I had a slightly different use case initially but it’s the same problem. Basically, higher-ordered UDFs.

I wanted to create a MapObject UDF today, with a Lambda function passed in as an argument.

Ahah, I should have led with Higher-Order UDF capability instead of giving a hacky example :smile: