https://kotlinlang.org logo
#getting-started
Title
# getting-started
p

Phani Mahesh

03/02/2022, 12:13 PM
Is there a way to restrict usage of external functions in a dsl? I’m thinking about creating and exposing a dsl using which users can provide their own domain spec. Is there a way to restrict them from using non whitelisted imports or language features?
s

Stephan Schroeder

03/03/2022, 12:36 PM
nope, the only instance of restricting normally valid kotlin code is the DslMarker-annotation that disallows invocation of methods from an "outer scope", see https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-dsl-marker/ for a better explanation. But it does a very specific thing and is not applicapble to restrict imports or other language features except one.
4 Views