« Return to Thread: something like Clojure's "doto"?

Re: something like Clojure's "doto"?

by gabriele renzi-5 :: Rate this Message:

Reply to Author | View in Thread

definitely, I just wrote this mail 4 days ago but sent it to the wrong
address and by the time I re-sent it the other thred had appeared :)

2009/7/17 Detering Dirk <Dirk.Detering@...>:

>> 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
>



--
blog en: http://www.riffraff.info
blog it: http://riffraff.blogsome.com

 « Return to Thread: something like Clojure's "doto"?