Steven Schveighoffer, el 18 de marzo a las 21:34 me escribiste:
> A proposed syntax:
> 
> final return this add(V v)
> {
>   bool ignored;
>   add(v, ignored);
>   // no return necessary?
> }
> 
> There's probably not a huge need for it, but I just thought I'd put
> the idea out there.

Or you can add a proper chain operator. OOC does that (I know they borrow
it from another place, I just don't remember from where):


        me := RandomGuy new()
        me eatBreakfast() .drinkCoffee() .yawn() .goBackToBed()

        Some smart people call that "message chaining". It's different
        from cascade calling, though, because eatBreakfast() and his
        friends don't return anything.

(in OOC a space " " is like a dot "." in D, and the dot is the chaining
operator)

I think this is a cleaner solution for that problem, you don't have to
annotate the methods with "return this" and when you read the code using
it, you know all the methods are being called on the *same* object, if you
do x.add(y).add(z), the second add could be called in an object other than
x.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------

Reply via email to