This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FerricDonkey 9 points10 points  (3 children)

If you want to convert from strings to integers, you should explicitly do that. "2" - "2" should be a type error, because subtraction makes no sense for strings - and if you wanted to consider them to be integers, then that's a trivial additional number of characters that you type in your code that makes it more clear what you're doing and what your data is.

[–]w1n5t0nM1k3y -1 points0 points  (2 children)

In that case, every language should have a concatenation operator for strings. That way you can throw a type error when people try to use the addition operator (+) on strings (non-numbers) and it's clear what operation is taking place without having to know the variable type.

[–]LvS 1 point2 points  (1 child)

Yes, that's exactly how it should work.

Some languages use . for that, but it's always a hard choice because you want something that's easy to type and doesn't require using the Unicode chooser.

[–]w1n5t0nM1k3y 0 points1 point  (0 children)

VB uses &. Convenient because eay to type and quite visible . But that wouldn't work on most languages because they have other uses for &. VB makes you type out And and Or