Open gaorlov opened 3 days ago
@gaorlov Is the motivation for this request a need to pass behavior into a module?
I can understand how that would make certain deployment scenarios easier, but it would be difficult to make this work with ARM's underlying execution model. Every resource
and module
statement is essentially a remote procedure call, and only data that can be represented as JSON is permitted to cross those boundaries today.
@jeskew that is totally fair. I want to be clear that i understand that it would be unreasonable for me to expect arm to support full closures and try to use contunuations or any other lisp-y wizardry. My hope is to have an interface that can be implemented by multiple types and have the ability to be executed without forcing the caller to explicitly call the underlying module.
In terms of limitations, help me understand the constraints better. I saw that map
and other functions can take a lambda
object that is expressible in json. Can those objects be made available outside the built in calls? Like how functions are defined, but assignable to a variable.
Is your feature request related to a problem? Please describe.
I maintain a set of modules that export a set of types that overlap in their interfaces, both in terms of data structure and functionality. While I can declare the type data structures in a way that lets me use "duck typing" to unify them:
Which allows me to pass either an
A
or aB
into a method that expects anInterface
. And if i'm missing a field it expects, i will get errors letting me know that i'm passing in an incompatible object.However, if I want
Interface
to define not just the properties, but also member methods, there's really not a way to do this today. There's no way to express that the interface expects a method to be present. Best I can do is to export the same function name in all my interface-bound modules.But now, I have to know what import brought in what functions in order to call them
Describe the solution you'd like
I would love to hear what the thoughts are on adding
lambdas
to the top-level data type set, since they are already present in the built-in functions likemap
.lambda(paramType*) outputType
func
would be reasonable:var
referencesUsing this proposal I can express the examples above as