Implicit conversion

50 views
Skip to first unread message

Spencer Alger

unread,
Jun 12, 2015, 3:09:11 AM6/12/15
to streng...@googlegroups.com
> Open Questions: Figure out which conversions to disable exactly, and which ones to keep. What about ‘+’ in particular?

I wonder if it would make sense to restrict '+' to numeric addition and require that template strings be used for concatenation.

Andreas Rossberg

unread,
Jun 12, 2015, 9:13:56 AM6/12/15
to Spencer Alger, streng...@googlegroups.com
On 12 June 2015 at 09:09, Spencer Alger <spencer...@gmail.com> wrote:
> Open Questions: Figure out which conversions to disable exactly, and which ones to keep. What about ‘+’ in particular?

I wonder if it would make sense to restrict '+' to numeric addition and require that template strings be used for concatenation.

We considered that (restricting + to numbers), but did not take that route, because + seems too useful as an operator for simply concatenating two strings. Moreover, there is similar overloading for <, >, <=, >=, which we cannot throw out.

So we still allow + on strings. We do, however, disallow implicit conversions, so either both arguments are numbers or both are strings (similarly for comparisons). For more complicated interpolation you are indeed expected to use template strings in strong mode.

/Andreas

Reply all
Reply to author
Forward
0 new messages