https://kotlinlang.org logo
k

keturn

05/28/2020, 6:28 PM
dsl patterns can lead to nested receivers, e.g.
Copy code
project { all X@{ register {  
  foo(this@X)
}}}
is there a way for that inline receiver function to give the receiver an explicit name, other than
this
, instead of using the
@
label?
(I hope you can forgive the brace placement for the sake of making it short in Slack)
s

Stefan Beyer

05/28/2020, 7:32 PM
are you the author of the dsl or the user?
k

keturn

05/28/2020, 7:36 PM
user
s

Stefan Beyer

05/28/2020, 7:40 PM
then i can only think of something like this:
Copy code
project {
 all {
  val subProject = this
  register {  
   foo(subProject)
  }
 }
}
feels clunky though ^^
k

keturn

05/28/2020, 7:43 PM
yeah. was wondering if there's some way to do it the same sort of way you can specify arguments in a lambda signature, but doesn't really look that way
4 Views