lua-users home
lua-l archive

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

> i think formally there's no difference between primitives 'value
> based' types and 'reference based'
> to me, it's more like this:
> - values have type
> - variables have no type
> - variables reference values
> - simple assignment and function parameters copy variables (that is,
> references), not values
> - there are immutable types (number, string, lightuserdata), and
> mutable types (table, function, full userdata)
> implementation detail: numbers and lightuserdatas are small enough to
> reside in the variable themselves and are copied around; but since
> they're immutable, it doesn't make any difference.
> IOW, the 'by value vs. by reference' is only an implementation detail
> and not a formal specification.  the behaviour must conform to the
> theoretical specification where every variable holds only a reference.

Quite good explanation.

-- Roberto