Hey! I've recently been dabbling around with BYOND code, using the reference as a tool to work with, and I've been somewhat curious about a certain something.

Is there any difference in functionality between a variable defined as 'test_variable' and 'src.test_variable', assuming the variable was defined for the source? I'm aware that if you define a mob as M, that you can access the variables for M though the same process (M.test_variable), so I'm really wondering if src.* is simply a redundant function due to the source being a mob with that variable, or if it actually does make a difference in some way. Would it make any difference if the source was a datom?

If my question didn't make much sense, let me know, I'll post a snippet of code to explain my question a little better.
As far as I'm aware, src is already implied. I never bother doing stuff like or src.desc in my code since there's no real reason to type src out.

There is one caveat however:

mob/verb/rename(name as text)
name = name

world << name

The above will not work at all. You'd have to do...

mob/verb/rename(name as text) = name

world << name

So that the compiler specifically knows you mean src's name variable, and not the local variable name. Obviously you can just not use name as the variable name and do something else like _name or newname so you don't have to do the thing.

Read Chapter 5. It's an easy, short read. Section 4 deals with what LordAndrew is talking about.
var test = "global"

var test = "object-level"

var test = "proc-level"
src << "[test], [src.test], [global.test]"

var test = "compile-time error"

var test = "compile-time error"
Wow, fast responses! =D

Thanks guys, this actually helps a bit; I forgot to take into consideration that there could very well be multiple variables using the same name on different levels.

Thanks for pointing out the guide, Airjoe. Actually, it was one of the things I used as study material, I'm not sure why I forgot about it. xD; Certainly a good reminder though!

EDIT: Hey, just figure I'd share my findings a little further from the help you've given me. Wrote a little hybrid code from what Kaiochao was trying to demonstrate.

test = "datom-level"
world << "[test], [src.test], [dat.test], [global.test]"
// Will return "proc-level, datom-level, datom-level, global"

test = "global"
datom/dat = new()

test = "mob-level"
world << "[test], [src.test], [dat.test], [global.test]"
// Will return "mob-level, mob-level, datom-level, global"
verb_level(test as text)
test = "verb-level"
world << "[test], [src.test], [dat.test], [global.test]"
// Will return "verb-level, mob-level, datom-level, global"

Edited the code a little. As it turns out, LordAndrew was correct; src is implied unless a verb or a proc has an argument under the same variable name.

Thanks again for the help, guys. =3