Limit root-level functions to DSL-scope

Is it possible to make a root-level-function only accesible from a certain DSL-scope?

If not, I propose an Idea to add a name in the DSL-annotation.
Then use an annotation on the root-level-method, like MarkedFor.

In that way, it would possible to add extension-functions to a limited scope of a library.
(at this moment, all those functions need to be declared on an interface).

1 Like

You might take a look at extension methods as members:

I know.
This means that the higher level classes need to know about the lower level methods.
That is at first not the smartest way.
A lot of this can be solved by using delegation.
(you can see this in KotlinPoetDSL, which depends heavily on this pattern.)

The problem occurs when you need to add functions add a later stage, or in the case of my library, if the users want to add things.

(I know, my DSL will probably not be used in the real world, but the problem probably will)