In the absence of OOP - which I understand, based on the model - it would still be nice to have delegates that can match particular actions, and that a delegate type could be a parameter for an action.
I actually made an attempt at making delegates/callbacks (attached) but late in the process, I got a rather stern lesson about how bad reflection is at handling structs in .NET.
I made it so that you could make a Structure with exactly the same layout as the Actions you were expecting to call, e.g.

...and then an example Action with those same parameters:

Then I had the actual Callbacks - here was my sample flow:

CreateCallback took the ESpace and the name of the Structure:

You could choose which Action to bind the Callback to via BindCallback:

Make a local variable of the Structure type and assign parameters to it:

...and then call the actual Callback with those parameters:

It almost worked. I could read things out of the parameters, and the breakpoint in TestEmailCallback got hit:

I couldn't get the results back, though. The ToObject(parameters) makes a boxed copy of the structure, and FieldInfo.SetValue(structure, value) actually makes a boxed copy of the structure every time it sets the field, and so loses the field.
There's __makeref and SetValueDirect and weird things like that, but absent being able to do that from the OutSystems side or being able to convert a generic object to a specific structure, I think I will have to abandon my efforts - or maybe thing of a less-cool way of doing it.
Anyhow, I'd like this as an OutSystems feature at some point so that I don't have to do weird things with Switches everywhere :)
Also, sorry for being a bit insane.
-- Ritchie Annand
This comment was:
- originally posted on idea 'Delegates' (created on 25 Apr 2018 by Jade Ritchie Annand)
- merged to idea 'Action,Destination as a parameter' on 21 Mar 2021 17:08:53 by Justin JamesThis comment was:
- originally posted on idea 'Action,Destination as a parameter' (created on 19 Aug 2014 by K N)
- merged to idea 'Allow Actions/Functions to be passed as a parameter' on 21 Mar 2021 17:10:26 by Justin James