moirai-lang / moirai-kt

A scripting language that calculates the worst-case execution time (WCET) before executing each script. Ideal for multi-tenant microservices, serverless functions, and computed columns in databases.
MIT License
26 stars 1 forks source link

Users no longer have Type visibility, and therefore cannot make plugins #50

Closed sithys closed 6 months ago

sithys commented 7 months ago

The plugin system assumed that users would be able to configure plugin type checking through the primitives provided in Symbol.kt or Type.kt, however this is no longer the case because of the heavy use of the internal keyword to establish a stable public surface.

One solution to this problem is to have an alternative syntax for declaring plugin signatures. For example:

record HttpResponse<K: Fin>(val code: Int, val body: String<K>)
plugin http<M, N>(s: String<M>): HttpResponse<N>

These little snippets would be parsed and the plugin type information would be available to the runtime. The user would be able to inject the body of the plugin by searching a dictionary for the plugin and associating the body with that plugin. At no point would the actual Type classes be exposed and they can remain internal in case they need to change in the future.

sithys commented 7 months ago

We can repurpose the planned metadata changes to Lang to solve this problem. We will still have a syntax that allows users to define the signature for plugins, it just will not be used in Lang.