[Runtime Proposal] Making "provide" also support export overrides

Proposal: Making “provide” also support export overrides.

The main idea of this proposal is to allow developers to create resources that can provide as well as override resource export invokation.

For this example, say we create a resource that is called example_bridge and provides for a resource called other_bridge.

We’ll say that example_bridge has the below code:

exports("GetValue", function() 
     return 1
end)

We’ll also say that other_bridge has the below code:

exports("GetValue", function() 
     return 2
end)

Currently, if example_bridge provides for other_bridge, it will not override the resource’s exports if it is missing.

print(exports["example_bridge"]:GetValue()) -- Will error, should print 1 in this proposal.
print(exports["other_bridge"]:GetValue()) -- Will NOT error, will print 2.

Checking if the target provide is currently started will avoid any conflicts, as it will simply use that resource’s exports as the priority.

Feel free to discuss this feature proposal below!

1 Like

The main reason this wasn’t implemented is that exports are currently still a bit of a hack internally based on events - I had some work pending that reworked both ref calls and then could be used to make exports a built-in concept as well, which would automatically handle provide support I believe.

5 Likes

Oh that’s awesome!

Yeah honestly that makes sense as to why it wasn’t implemented initially, would love to help implement it but I’m not educated enough on software development yet.

I really appreciate your fast and detailed response!