"jbrave" wrote:
So is this:
obj=GetObject()
function Getobject() as object
return
{action:functionname
action2:function2name
variable:"value"}
end function
Being used as a method? Can you elaborate a little bit?
I would say that GetObject is a function that generates an object.
Calling obj.action() would be using the "action" method of the "obj" object that the GetObject() function created. I use method to refer to a function that operates within the context of an object, and function to refer to a stand-alone function.
Calling functionname() would be calling the same bit of code as obj.action() above, but the "m" variable would refer to something different (the global m object as opposed to the object's data).
In summary, functions can use m and access a global data store, or "global object" if you prefer, while methods can use m to access the object's data. Currently you can't use a function as a method (assign to a object variable) and have it access the global data though m.
If you really want globals within methods, create yourself some helper functions like so:
function setGlobal(name as string, value as dynamic)
m[name] = value
end function
function getGlobal(name as string) as dynamic
return m[name]
end function
and use those to set/get global values. It's also far less ambiguous what you are accessing, so there won't be any confusion between accessing object data and global data.
P.S. I haven't actually bothered to use the above in production, but barring any simple typo problems, I think they should work.
-- GandK Labs
Check out Reversi! in the channel store!