###Delegate
Delegate
###Delegate
Delegate
Set x = Delegate.Create("(x) => MsgBox(""Hello, "" & x & ""!"")")
x.Execute("Mug")
Appending the expression body to the function's name induces a limitation - the "body" may only be a one-liner. I can live with that, but I wonder if there wouldn't be a way to make it smarter.
Set x = Delegate.Create("(x) => MsgBox(""Hello, "" & x & ""!"")")
x.Execute("Mug")
Set x = Delegate.Create("(x) => MsgBox(""Hello, "" & x & ""!"")")
x.Execute"Mug"
Appending the expression body to the function's name induces a limitation - the "body" may only be a one-liner. I can live with that, but I wonder if there wouldn't be a way to make it smarter.
The actual anonymous function doesn't get generated until the Execute
function is called, and then the anonymous function gets destroyed before Execute
exits - this way one could have 20 Delegate
objects with as many different anonymous functions waiting to be executed. The flipside is an obvious performance hit, especially with usages such as the Where
method shown above - the same method would get created, executed and destroyed 200 times if the encapsulated collection has 200 elements.
The actual anonymous function doesn't get generated until the Execute
function is called, and then the anonymous function gets destroyed before Execute
exits - this way one could have 20 Delegate
objects with as many different anonymous functions waiting to be executed.
The actual anonymous function doesn't get generated until the Execute
function is called, and then the anonymous function gets destroyed before Execute
exits - this way one could have 20 Delegate
objects with as many different anonymous functions waiting to be executed. The flipside is an obvious performance hit, especially with usages such as the Where
method shown above - the same method would get created, executed and destroyed 200 times if the encapsulated collection has 200 elements.