RE: something like Clojure's "doto"?
> The second I guess would be the more correct but it forces
> client side import. Ideally, one should be able to abstract
> it away, e.g.
>
> doto(x) { //no additional boilerplate
> foo(1) // calls x.foo(1)
> bar(2) // calls x.bar(2)
> }
Hmmm. That would allow for the following?
class MyClass {
def someMethod(f: =>Unit) {
doto(this) f
}
def otherMethod() { ... }
}
val x = new MyClass()
x.someMethod {
otherMethod()
}
If yes, that would be the answer (or better: it is the same question)
for thread "Question on DSL", because that resembles the Groovy
closure delegate feature. It would be great for creating
builder based DSLs.
KR
Det