News for hackers. Stuff that matters.
Re:John Carmack working on Scheme as a VR scripting language by TazeTSchnitzel on Wednesday July 01, 2015 @07:41AM (#9811204)
> Lua is not weakly typed (at least not in the sense of Javascript and PHP where "3"+4 is either 7 or 34, can't remember which.

In JS, "3" + 4 is "34", in PHP, it's 7. PHP separates concatenation and addition, unlike JS.

Anyway, huh? Lua has automatic type conversion. That's usually considered weak typing.

Re:John Carmack working on Scheme as a VR scripting language by ufo on Wednesday July 01, 2015 @11:41AM (#9812596)
Its just for "+" and ".." though. For other things, such as equality and table indexing numbers and strings are not interchangeable.
Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:08AM (#9811300)
In Lua "3"+4 is an error. Concatenation is a different operator than add, specifically to avoid confusing coersions.
Re:John Carmack working on Scheme as a VR scripting language by ggilles on Wednesday July 01, 2015 @08:35AM (#9811407)
Try it:

    Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
    > ="3" + 4
    7
Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:42AM (#9811451)
Ah. Well at least there isn't a confusion between add and concat

"3"+4 is 7 4.."3" is "43"

"3hello"+4 is an error

Re:John Carmack working on Scheme as a VR scripting language by beagle3 on Wednesday July 01, 2015 @10:39AM (#9812096)
Stand corrected with the example. I forgot about the lua auto type conversion - but that, on its own does not make weak typing - Python, C and Java do that between floats and ints, would you consider them weak typed?

I'm not familiar with a rigorous definition of weak typing - but my experience is that weak typing is usually reserved for languages like TCL, Snobol, and even Perl where there's no "type" of values to speak of - everything is equivalent and decoded according to context.

Re:John Carmack working on Scheme as a VR scripting language by superfunc on Wednesday July 01, 2015 @11:45AM (#9812645)
That's the problem with those terms, both 'weak' and 'strong' typing are purely subjective.