On 10 Sep 2015, at 18:38, Chris Muller <asqueaker@gmail.com> wrote:
I generally agree about implicit type-conversions, but I don't really think this one is all that implicit. String concatentation returns a String, no exceptions.
By not having this for Strings actually led to Andreas getting bitten, which is why it was added to Squeak. The "bite" comes when your program encounters an error, and in your error-handler you wrote a descriptive message, 'It didn''t work because the value is ', someOtherString. Except someOtherString is nil. Now your error-handler itself has an error, blowing up and leading you on a wild goose chase because of a trivial message-concatentation problem instead of the real problem.
Can you describe an example where you feel this one could potentially bite you by its "implicitnessâ?
Thatâs a mean question :) I canât think of an example that is directly related but consider this method: doSomethingWith: someObject self printThisOntoAWebPage: âmy literal â, someObject The intention here is to print something out and âsomeObjectâ is supposed to have a certain format. Letâs say that âsomeObjectâ is a Date object and I want it to be printed as dd.mm.yyyy. The implicit conversion would yield âmy literal 10 September 2015â instead of the expected âmy literal 10.09.2015â. With an exception I would have seen that I need to format that object first, with implicit conversion I might overlook the mistake. Yes, itâs quite the construct I built here but in my experience the truth isnât that far away from it. Cheers, Max
On Thu, Sep 10, 2015 at 9:34 AM, Max Leske <maxleske@gmail.com> wrote:
Iâm with Sven on this. Just because JavaScript implementations (and others) choose to perform implicit type conversion doesnât mean itâs a good thing. It might make it easier for newcomers to write a hello world program but it will bite you when youâre trying to do actual work.
On 10 Sep 2015, at 16:16, Sven Van Caekenberghe <sven@stfx.eu> wrote:
No, this is not a good idea (silent conversions). It is one of the original differences between Pharo and Squeak. Try searching the MLs, I am sure it is all still there.
You can also concatenate exceptions to create an exception set, I am sure there are other examples.
On 10 Sep 2015, at 16:12, Aliaksei Syrel <alex.syrel@gmail.com> wrote:
Hi
I'm just curious why "," doesn't convert object to string during concatenation?
For example I expect 'answer is ', 42 to return 'answer is 42' instead of 'SmallInteger are not indexable'.
Of course you could say that 'answer is ', 42 asString does the job... but still why not to put asString in concatenation method
Cheers, Alex