[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Arguments by reference?
- From: "Brent Arias" <barias@...>
- Date: Thu, 1 Sep 2005 12:49:11 -0700
So in Lua:
both do exactly the same thing: somefunc is passed the value, which is
3 or someobj, respectively. It cannot mutate 3, so the difference is
ignorable, but it may be able to mutate someobj (if someobj were a
mutable object), and if it does, it is mutating the same value as was
passed to it.
Ok, so provided the object isn't const, then the summary (in my lingo) is:
lua passes primitives by value, and ADTs by reference.
I presume you'll tell me I'm mistaken, but man I gotta tell you, the
explanation of why passing by reference in lua, is not passing by
reference - is altogether too esoteric for me. :)
Don't feel bad, the C# people can't help me either. Every stupid C# book
explains that arguments are passed by value reference types that are values,
not references, but are passed as references but not called references. ya.
Incidentally, I have many books on C# - and none of them have made a
sensible explanation of what is happening in C# argument passing (they
invariably contradict themselves from sentence to sentence, and paragraph to
paragraph on this particular topic). Perhaps I just need a brain upgrade
for C# or lua mastery. :(