lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 11/8/2012 10:53 AM, David Given wrote:
> It's much easier to think of this as *all* values being passed by
> reference... it's just that numbers, like strings, are immutable and
> cannot be changed.


We may need a beginner to test your theory on, but I am extremely skeptical.

People new to programming have a hard time thinking in abstractions. Period. Talking about a=a+1 creating a "new value" and assigning a reference to "a" rather than adding one to "a" is a level of abstraction that I would almost guarantee make a beginner's eyes glaze over. The more concrete you can make a concept, the easier it is to grasp.

As an experienced Lua developer (and programmer in general), I actually find the concept quite elegant. This thread is about introducing beginners, though, and to my mind that includes beginning programmers. And you want to keep the concepts as simple as possible as you're introducing any language to a complete beginner.

AND...if I'm right and it's easier for a beginner to think in terms of variables holding values, then you end up with the value/reference distinction, where some "values" (e.g., tables) are actually references to a single table, and not distinct copies of the table.

Tim