On Wednesday, 4 June 2014 at 22:02:37 UTC, Adam D. Ruppe wrote:
Yeah, I'm generally against it... but I have a weird view of typing.


The way I see it, you should go either strong and static or dynamic and weak - I hate the middle ground.

So, in my view:

Best (like D):
string a = "10"; int b = 20;
a + b; // compile time error: cannot do string + int

Sometimes ok (my jsvar/script language also PHP and some others):
var a = "10"; var b = 20;
a + b; // 30

Blargh (javascript):
var a = "10"; var b = 20;
a + b; // "1020"

Hatred:
var a = "10"; var b = 20;
a + b; // throws an exception at run time


Yup, you choose the right tradeoff. I wish std.json has something
in the same style as our jsvar.

The D one is best because it draws your attention to something that is imperfect immediately and reliably via a compilation error. Then you can solve it with to!int or
whatever easily.

The weak+dynamic is passable to me because it actually mostly works. The operator you choose coerces the arguments and gives something basically usable. I'd be ok if it threw an exception in the case of a string that cannot be sanely converted to int, but if it can be made to work, just do it.


We all have to handle JSON or XML or some other thing like that
at some point. When it come to these, having variant typing is
huge for ease of use.

Reply via email to