4 ms·
It sounds neat. I've wanted this kind of thing when I programmed in languages that didn't have it. But having gone from c++ to Ruby to C++, I think the benefit
by joe_the_user 13y ago
It sounds neat. I've wanted this kind of thing when I programmed in languages that didn't have it.
But having gone from c++ to Ruby to C++, I think the benefits of this expressiveness may not really be there.
This construction makes each line of the whole program that much longer, it asks that every functions arguments be meaningful outside the context of the function as well as within. Basically, this syntax may show you that certain calls are wrong but there are many other calls it won't prevent and it gives you larger amount of code to page through to find those other errors.
Remember, a good program wouldn't be using 10 as a function input except if there was some reason it's meaning was clear. And a rect would take two points rather than four ambiguous ints.
So what you can have is drawRect(Pt(screenLeft, screenTop), Pt(screenRight, screenBottom) if you want a rect covering the screen and you want expressiveness.
- benjComan 13y agoIn Smalltalk you define points with '@' so you could do... drawRectOrigin: 50@50 extent: 10@21. drawRectOrigin: 50@50 corner: 60@71. If you really wanted, on class Point you could define method ',' with parameter 'otherPoint' as follows... , otherPoint ^ Rectangle origin: self corner: otherPoint. then you could do draw rectangles like this... drawRect: (50@50),(60@71). drawRect: (screenLeft@screenTop),(screenRight@screenBottom).